Program 10:
#include<stdio.h> main()
{
int dummy,n,rev=0,x;
printf("Enter a number\n");
scanf("%d",&n);
dummy=n;
while(n>0)
{
x=n%10;
rev=rev*10+x;
n=n/10;
}
if(dummy==rev)
printf("The given number %d is a palindrome\n",rev);
else
printf("The given number %d is not a palindrome\n",rev);
}
Explanation:
- This is same as reversing a number which is Program 9 . To print reverse of a number
- Just we used dummy variable to check whether the reversed number is same as the original one(i.e. 'n').
- for example if n=321=dummy then the reverse rev=123.
- As dummy is not equal to rev then the output is not a palindrome.(Here we can't use 'n' as it become 0 at the end of the loop which is why we are using a variable 'dummy' for temporary storage of the value).



