C Program to check a number is palindrome or not


In this program, You will learn how to check a number is palindrome or not in C.


Some list of palindrome numbers is : 11, 121, 111, 81218


Example: How to check a number is palindrome or not in C

Run it Now
#include<stdio.h>

int main() {

   int n, num, r, rev = 0;
   printf("Enter a Number :");
   scanf("%d", &n);

   num = n;
   while (n > 0) {
       r = n % 10;
       rev = rev * 10 + r;
       n = n / 10;
   }

   if (num == rev) {
       printf("\nNumber is Palindrome :%d", num);
   } else {
       printf("\nNumber is Not Palindrome :%d", num);
   }

   return 0;
}

Output:

Enter a Number :121
Number is Palindrome :121