Here's a code to find out if the number is palindrome or not.
#include <stdio.h>
int main()
{
int num,chknum1,chknum2=0,i,rmndr;/*here rmndr is remainder after mod,chknum is reversed num*/
printf("enter the number");
scanf("%d",&num);
chknum1=num;/*saving num,since it is manipulated*/
for(i=0;i<=sizeof(chknum1);i++)
{
rmndr=num%10;
num=num/10;
chknum2=chknum2*10+rmndr;
}
printf("chknum1 %d,chknum2 %d",chknum1,chknum2);
//if(chknum1=chknum2)
//printf("Is palindrome");
//else
//printf("is not palindrome.");
return 0;
}
But it prints couple of extra zeros when the number is reversed,hence will fail to tell if the number is palindrome or not.
Can anyone tell me what am I missing?