C Program Palindrome
/* Write a program to find whether a number is palindrome or not. */
#include <stdio.h>
int main(void) {
int no,sum=0,temp;
printf("Enter Number : ");
scanf("%d",&no);
temp=no;
while(no>0)
{
sum = (sum * 10)+(no % 10);
no = no / 10;
}
if(temp == sum)
{
printf("\n %d is Palindrome",temp);
}
else
{
printf("\n %d is not Palindrome",temp);
}
return 0;
}
#include <stdio.h>
int main(void) {
int no,sum=0,temp;
printf("Enter Number : ");
scanf("%d",&no);
temp=no;
while(no>0)
{
sum = (sum * 10)+(no % 10);
no = no / 10;
}
if(temp == sum)
{
printf("\n %d is Palindrome",temp);
}
else
{
printf("\n %d is not Palindrome",temp);
}
return 0;
}
Comments
Post a Comment