Wednesday, August 24, 2011

Validate if given number is Palindrome or not

#include <stdio.h>
int main(void)
{
int i,num,rev= 0,j = 0;
printf("Enter a number for Palindrome check :");
scanf("%d",&i);
num = i;

while ( i != 0 )
{
rev = i % 10;
j = rev + j * 10 ;
i = i / 10 ;
}

if ( j == num)
printf("\n %d is palindrome",num);
else
printf("\n %d is not Palindrome\n",num);
return 0;

}