Pages

Saturday, 20 June 2015

Palindrome number

Check a given number is palindrome or not

Coding:
#include
int main()
{
int n,rn=0,r,no;
printf("Please enter the number:");
scanf("%d",&n);
no=n;
while(n>0)
{
r=n%10;
n=n/10;
rn=rn*10+r;
}
if(no==rn)
printf("%d is a palindrome number",no);
else
printf("%d is not a palindrome number",no);
return 0;
}

Output:
Please enter the number:121
121 is a palindrome number