What is palindrome number ?

A palindrome is a number that remains same when its digits are reversed. It’s more like mirror of its own.

For example 12321

For better understanding of program, you must be familiar with following c programming concepts

C program to check palindrome number

``````/* C program to check whether given number is palindrome or not */
#include <stdio.h>

int main ()
{
int num, reverse = 0, remainder, temp;
// reverse is used to store to reverse number
printf("Enter the number: ");
scanf("%d", &num);

temp = num; // original number is stored in temp variable

while( temp != 0)
{
remainder = temp % 10;
reverse = reverse * 10 + remainder;
temp = temp / 10;
}

if (num == reverse) // checking whether num is equal to reverse
printf("%d is a palindrome.", num);
else
printf("\n %d is not a palindrome.", num);
return 0;
}``````

Output

Explanation

First of all, given number is stored in `temp` variable. Inside `while` loop the original number is divided and reversed which is stored in `reverse` variable.

Finally, `if` condition checks whether the original number is equal to reverse or not.