Check for palindrome number

  • November 12, 2022
  • C++
Accessing Elements

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:

using namespace std;

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

        cout<<n<<" is a palindrome number";
        cout<<n<<" is not a palindrome number";

int main(){
    int num;
    cout<<"Enter the number: ";
    return 0;
Enter the number: 112232211
112232211 is a palindrome number

Note: also read about Check for Prime number

Follow Me

Please follow me to read my latest post on programming and technology if you like my post.

Leave a Reply

Your email address will not be published. Required fields are marked *