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.
#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("Number is palindrome:%d", num);
} else {
printf("Number is not palindrome:%d", num);
}
return 0;
}
Output:
Enter a number:121
Number is palindrome:121