Program to check if a number is palindrome (reverse a number) in C++

Program to check if a number is palindrome (reverse a number) in C++

Reverse a number using the function reverse() given below. the execution of following code will tell you if the input number is palindrome (Number / text which when reversed is the same)

/* Palindrome numbers program

   © Code Nirvana*/

#include<iostream>

#include<conio.h>

using namespace std;

int reverse(int);

int main()

{

      int num;

      cout<<"Enter The number"<<endl;

      cin>>num;

      cout<<"The reverse is "<<reverse(num)<<endl;;

      if(reverse(num)==num) cout<<"It is a palindrome number";

      else cout<<"Not a palindrome number";

      getch();

      return 0;

}

int reverse(int a)

{

      int temp=0;

      for(;a!=0;a/=10)

        {

           temp=temp*10+(a%10);

        }

      return temp;

}


OUTPUT :


Output of palindrome

Output of palindrome

4 Comments Leave new

i want program for pattern:
1
2 3
6 5 4
7 8 9 10
15 14 13 12 11
if i give input as n=5

Reply

i want program for pattern:
1
2 3
6 5 4
7 8 9 10
15 14 13 12 11
if i give input as n=5

Reply

what is the significance or meaning of +a+ and +a

Reply

Can you provide me more pattern and pyramid design of java for practice wchich should be typical.....

Reply

Make sure you tick the "Notify Me" box below the comment form to be notified of follow up comments and replies.