C++ Online Compiler
Example: C++ Program to Check Palindrome Number using While loop
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ Program to Check Palindrome Number using While loop #include <iostream> using namespace std; int main() { int x, r, rN = 0, oN; // rN - To store the reverse number // oN - To store the original number // r - To store the remainder cout << "Enter an integer number::\n"; cin >> 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) { cout << "The " << oN << " is a palindrome number."; } else { cout << "The " << oN << " is not a palindrome number!"; } return 0; }
90009
Output
Clear
ADVERTISEMENTS