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 number is : 11, 22, 33, 101, 222.


Example: How to check a number is palindrome or not in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int x, t;
    int r, rev = 0;

    cout << "Enter A Number :";
    cin>>x;

    t = x;
    while (x > 0) {
        r = x % 10;
        rev = rev * 10 + r;
        x = x / 10;
    }

    if (t == rev) {
        cout << "\nNumber is Palindrome :" << rev;
    } else {
        cout << "\nNumber is not Palindrome :" << rev;
    }

    return 0;
}

Output:

Enter A Number :232
Number is Palindrome :232