Check if number is palindrome using while loop

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

Solution:

#include<stdio.h>
int main()
{
      int r=0,l,num;
      long n;
      printf("Enter Number : ");
      scanf("%ld",&n);
      num=n; //copy original number
      while(n>0)
      {
            l=n%10;
            r=r*10+l;
            n=n/10;
      }
      printf("\nReverse Number : %d",r);
      if(r==num)
            printf("\n\n%d is Palindrome Number.",num);
      else
            printf("\n\n%d is NOT Palindrome Number.",num);
      return 0;
}


Output:

palindrome num