C Program to check whether number is palindrome or not
Write a C program to enter any number and check whether given number is palindrome or not using for loop. How to check whether a number is palindrome or not in C programming. C program for palindrome numbers.
If a number remains same, even if we reverse its digits then the number is known as palindrome number. For example 12321 is a palindrome number because it remains same if we reverse its digits.
Get the number from user.
Compare it with the number entered by the user.
If both are same then print palindrome number
Else print not a palindrome number.
Enter a number: 121
Output: 121 is Palindrome
Here is source code of the C program to checks whether number is palindrome or not. The C program is successfully compiled and run on a Windows system. The program output is also shown below.
SOURCE CODE : :
long int n, num, rev = 0, dig;
printf("\n\nENTER A NUMBER----: ");
n = num;
dig = num % 10;
rev = rev * 10 + dig;
num = num / 10;
if (n == rev)
printf("\nGIVEN NUMBER IS A PALINDROME");
printf("\nGIVEN NUMBER IS NOT A PALINDROME");
OUTPUT : :
ENTER A NUMBER----: 141
GIVEN NUMBER IS A PALINDROME