C program to check palindrome number using while loop or not using function of any number
ADVERTISEMENTS
C program to check palindrome number using a while loop or not using a function of any number. In this program, you will learn that how to check an integer number is a palindrome or not?
What is a palindrome?
A palindrome is a case where if the reverse of any number will be matched correctly with its original integer number, It will be a palindrome.
Case example:
7997 == 7997 => a palindrome
Let us understand this concept through a c programming example:
// C program to check the palindrome of any integer number
#include <stdio.h>
int main() {
int x, r, rN = 0, oN;
// rN - denotes reverse number
// oN - denotes original number
// r - denotes remainder
printf("Enter an integer number::\n");
scanf("%d", &x);
oN = x;
// reverse number will be stored during iteration
while (x != 0) {
r = x % 10;
rN = rN * 10 + r;
x /= 10;
}
// if original number will match with reverse then palindrome case will be true
if (oN == rN) {
printf("The %d is a palindrome number.", oN);
} else {
printf("The %d is not a palindrome number!", oN);
}
return 0;
}
Output:
Enter an integer number::
90009
The 90009 is a palindrome number.
90009
The 90009 is a palindrome number.
Tags:
palindrome program in c without using string functions
palindrome program in c++
write a program to find whether a string is palindrome or not
palindrome program in c using for loop