Check Palindrome Number

Check Palindrome Number” is very basic and important programming exercise problem. Here, we are given an integer, entered by user and our task is to write a program to check whether an entered number is palindromic number or not.

A palindromic number is a number which is when reversed stays the same number.

Examples of Palindromic Number are 22, 212, 33433 etc.

The steps required to check palindrome number are as follows:

  1. Scan a number from a user and copy that number to temporary variable.
  2. Initialize a reverse_number with 0.
  3. Now, one by one fetch out the last digit from a number using modulus operator and concatenate to reverse_number.
  4. Now, check whether reversed_number and temporary variable number are same or not. 
  5. If they are same, then given number is palindromic number. Else, given number is not palindromic number.

C++ Program to check palindrome number is as follows:

/* C++ Program to check palindrome number */
#include<bits/stdc++.h>  
using namespace std;  
int main()  
{  
    //Scan the number  
    int num;  
    cout<<"Enter the number:";  
    cin>>num;  
      
  
    // Reverse the number  
    int temp = num;  
    int reverse = 0;  
    while(temp > 0)  
    {  
        int digit = temp % 10;  
        reverse = reverse*10 + digit;  
        temp = temp/10;  
    }  
      
    // Check Palindrome number  
    if(num == reverse)  
    cout<<num<<" is Palindromic Number";  
    else  
    cout<<num<<" is not Palindromic Number";  
}  
OUTPUT:
Enter the number:7117 
7117 is Palindromic Number

Related Posts:

  1. Program to find and print nth Fibonacci number.
  2. Program to find Power of the Number.
  3. Program to find Quotient and Remainder.
  4. Program to find largest amongst three numbers.
  5. Program to find factorial of a number.
  6. Program to find GCD of two numbers.
  7. Program to find LCM of two numbers.
  8. Program to check whether entered number is odd or even.
  9. Program to check whether entered number is prime number or not.
  10. Program to check whether entered number is Armstrong Number or Not.
  11. Program to convert binary number to octal number.
  12. Program to convert binary number to decimal number.
  13. Program to convert binary number to hexadecimal number.
  14. Program to convert octal number to binary number.
  15. Program to convert octal number to decimal number.
  16. Program to convert octal number to hexadecimal number.
  17. Program to convert decimal number to binary number.
  18. Program to convert decimal number to octal number.
  19. Program to convert decimal number to hexadecimal number.
  20. Program to convert hexadecimal number to binary number.

You may also like...