# Check for palindrome number

• November 12, 2022
• C++

A palindrome number is a number that remains the same when digits are reversed. For example, the number 125521 is a palindrome number, but 1451 is not.

Program Logic:

• First, Declare a variable reverseNum and initialize it with 0.
• Now, make a while loop till the original number is greater than zero.
• In every loop, get the last digit of the number and add that digit at the end of the reverseNum and then, divide the original number by 10.
``reverseNum = reverseNum * 10 + (number % 10)``
• Lastly, check if the original number and reverseNum number are equal or not.

Program code:

``````#include<bits/stdc++.h>
using namespace std;

void check_palin(int n){
int temp=n;
int reverseNum=0;
do
{
int r = temp % 10;
reverseNum = (reverseNum * 10) + r;
temp = temp / 10;
} while (temp != 0);

if(n==reverseNum){
cout<<n<<" is a palindrome number";
}
else{
cout<<n<<" is not a palindrome number";
}
}

int main(){
int num;
cout<<"Enter the number: ";
cin>>num;
check_palin(num);
return 0;
}``````
##### Output:
``````Enter the number: 112232211
112232211 is a palindrome number``````