C Program to check whether the number is palindrome or not

#include<stdio.h>
int main()
{
  int n,num;
  printf("Enter a number\n");
  scanf("%d",&n);
  int reversed_number=0,rem;
  num=n;
  while(n!=0)
  {
    rem=n%10;
    reversed_number=reversed_number*10+rem;
    n=n/10;

  }
  if(reversed_number==num)
  {
      printf("%d is palindrome \n",num);
  }
  else
  {
      printf("%d is not a palindrome\n",num);
  }
}

Output:
C Program to check whether the number is palindrome or not


C Program to check whether the number is palindrome or not

Comments