C Program to Check Whether a Number is Palindrome or Not
In this example, we will learn to check whether the number entered by the user is a palindrome or not.
Remainder :
To understand this example, we should have the knowledge of the following C programming topics:
What is a Palindrome Number ?
A palindromic number is a number that remains the same when its digits are reversed.
For example :- 343 is a palindrome numbers because the reverse of 343 is 343.
Program to Check Palindrome Number
#include <stdio.h>
int main() {
int num, remainder, originalNum, reversedNum = 0;
printf("Enter a Number : ");
scanf("%d", &num);
originalNum = num;
while (num != 0) {
remainder = num % 10;
reversedNum = reversedNum * 10 + remainder;
num /= 10;
}
if (originalNum == reversedNum)
printf("%d is a palindrome number", originalNum);
else
printf("%d is not a palindrome number", originalNum);
return 0;
}
Output
Enter a Number : 454
454 is a palindrome number