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 whether a number is palindrome or not 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 whether an integer is palindrome or not is as follows:

#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 check whether entered number is Armstrong Number or Not.
  2. Program to convert binary number to octal number.
  3. Program to convert binary number to decimal number.
  4. Program to convert binary number to hexadecimal number.
  5. Program to convert octal number to binary number.
  6. Program to convert octal number to decimal number.
  7. Program to convert octal number to hexadecimal number.
  8. Program to convert decimal number to binary number.
  9. Program to convert decimal number to octal number.
  10. Program to convert decimal number to hexadecimal number.
  11. Program to convert hexadecimal number to binary number.
  12. Program to convert hexadecimal number to octal number.
  13. Program to convert hexadecimal number to decimal number.
  14. Program to check Leap Year.
  15. Program to find Power of the Number.
  16. Program to find Quotient and Remainder.
  17. Program to find largest amongst three numbers.
  18. Program to find factorial of a number.
  19. Program to find GCD of two numbers.
  20. Program to find LCM of two numbers.

You may also like...

Leave a Reply

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