C program to check whether a number is palindrome or not

C program to check whether a number is palindrome or not.

#include<stdio.h>
int main()
{
  int m,n,r,t;
  printf("\nEnter a number:=");
  scanf("%d",&n); //n=1221
  t=n; //t=1221
  r=0;
  while(n>0)
  {
    m=n%10;
    r=r*10+m;
    n=n/10;
  } //r=1221
if(t==r)
  printf("\nNumber is palendrome");
else
  printf("\nNumber is not palendrome");
return 0;
}
Spread the love
Back to: C Programming Language
Spread the love