fastread homefastrread library fastread menu

C++ : Check Whether a Number is Palindrome or Not

Tutorial by:Manisha Dubey      Date: 2016-06-18 04:22:49

❰ Previous Next ❱

This program takes an integer from user and that integer is reversed. If the reversed integer is equal to the integer entered by user then, that number is a palindrome if not that number is not a palindrome.

C Program to Check Palindrome Number

/* C++ program to check whether a number is palindrome or not */

#include <iostream>
using namespace std;

int main()
  int n, num, digit, rev = 0;
     cout << "Enter a positive number: ";
     cin >> num;
     n = num;
         digit = num%10;
         rev = (rev*10) + digit;
         num = num/10;
     }while (num!=0);
     cout << " The reverse of the number is: " << rev << endl;
     if (n==rev)
       cout << " The number is a palindrome";
       cout << " The number is not a palindrome";

    return 0;


Enter a positive number: 12321
The reverse of the number is: 12321
The number is a palindrome

Enter a positive number: 12331
The reverse of the number is: 13321
The number is not a palindrome

❰ Previous Next ❱


Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website