C example part 18 check palindrome number

#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);

}
Output:
Enter a number
343
The given number 343 is a palindrome
Explanation:
  1. This is same as reversing a number which is Program 9 . To print reverse of a number
  2. Just we used dummy variable to check whether the reversed number is same as the original one(i.e. 'n').
  3. for example if n=321=dummy then the reverse rev=123.
  4. 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).