Palindrome number

A palindrome is a word that has the same meaning when read backwards as when read from the front. Examples of palindromes are: Anna, madam, level, racecar and many more.
Mathematics also knows palindromes. Here we talk about palindromes if the numbers do not change when the sequence of numbers is reversed, for example 22 or 141.

Check Palindrome number

#include <iostream>
using namespace std;

int main(){
    int x, temp, r, rev = 0;
    cout << "Enter number to check palindrome or not" << endl;
    cin >> x;
    temp = x;

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

    if (temp == rev) {
        cout << temp << " is palindrome number" << endl;
    } else {
        cout << temp << " is not palindrome number" << endl;
    }

    return 0;
}
Output
Enter number to check palindrome or not: 262
262 is palindrome number

Enter number to check palindrome or not: 13
13 is not palindrome number

Check Palindrome number or string

#include <iostream>
using namespace std;

int main(){
    string str, reverse = "";

    cout << "Enter a string or number to check palindrome number: ";
    cin >> str;

    int length = str.length();

    for (int i = length - 1; i >= 0; i--) {
        reverse = reverse + str.at(i);
    }

    if (str == reverse) {
        cout << str << " is a palindrome." << endl;
    } else {
         cout << str << "isn't a palindrome." << endl;
    }

    return 0;
}
Output
wow is a palindrome.