Tuesday, 9 December 2014

C Program to print a number is palindrome or no

Program to print a number is palindrome or not
#include<stdio.h>
#include<string.h> 
main()
{
int n,i,result=0,num;
printf("enter any number...\n");
scanf("%d",&num);
printf("number before reverse..%d\n",num);
n=num;
while(n>0)
{
result=result*10;
result=result+(n%10);
n=n/10;
}
if(num==result)
printf("number is palindrome\n");
else
printf("not a palindrome number...\n");
}
OutPut:
enter any number...
121
number before reverse..121
number is palindrome
madan@madan-Lenovo-G570:~/madan$ ./a.out
enter any number...
123
number before reverse..123
not a palindrome number...