C Program to check palindrome numbers

Simple C program to check palindrome numbers: Palindrome number is a number which does not change if we reverse it. For example some numbers are 121, 123321,88988. To check palindrome number, reverse it and compare with original number.
#include<stdio.h>
int main()
{
 int n,temp,reverse=0;
 printf("Enter a number: ");
 scanf("%d",&n);
 temp=n;
 while(n!=0)
 {
  reverse=reverse*10;
  reverse=reverse+n%10;
  n=n/10;
 }
 if(reverse==temp)
 {
  printf("Number is palindrome\n");
 }
 else
 {
  printf("Number is not palindrome\n");
 }
 return 0;
}







Popular posts from this blog