C Program to Check the Number is Palindrome or Not

Write a C Program to check whether the number is palindrome or not?

What is Palindrome number?
A palindrome is a number that remains the same when its digits are reversed.For example – 1551,121,32423, etc, if these digits are reversed then also we get the same result.The term palindromic is derived from palindrome, which refers to a word (such as rotor or racecar) whose spelling is unchanged when its letters are reversed.
This program reverses an integer (entered by the user) using while loop. Then, if statement is used to check whether the reversed number is equal to the original number or not.

C Programming code for Palindrome number or not:

#include<stdio.h>
int integer( int n )
{
int rem,rev=0,a;
a=n;
while( n!=0 )
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
if ( a == rev)
{
printf(“%d is a palindrome”,a);
}
else
{
printf(“%d is a not palindrome”,a);
}
}
int main()
{
int num,a;
printf(“enter the num”);
scanf(“%d”,&num);
integer( num );
return 0;
}

Logic behind this program to check number is palindrome or not:

1. Input a number from user. Store it in some variable.
2. Find reverse of the given number. Store it in some variable say reverse.
3. Compare it with the number entered by the user.
4. If both are the same then print palindrome number else print not a palindrome number.