# C++ Program to Check Palindrome Number

Last updated on:

In this tutorial, we will learn about Palindrome numbers in C++ i.e. how to write a program to check whether a number is a Palindrome or not using C++.

## Quick Info:ðŸ’¡

â†ª An integer is considered as Palindrome if the reverse of the number is equal to its original number.

â†ª For example, 121, 343, 1221, etc are the palindrome numbers.

â†ª Hereâ€™s the following steps to check palindrome:

Code to check palindrome number can be performed in two ways:

## Palindrome Number in C++

Hereâ€™s a direct method to check a palindrome number.

Simply, the user will be asked to enter an integer then, the number is computed according to code provided and then displayed to a user.

### Example:

#include<iostream.h>
#include<conio.h>
void main()
{
int num,rev=0,rem,temp;
cout<<"enter a number:=";
cin>>num;
temp=num;
while(temp>0)
{
rem=temp%10;
rev=rev*10+rem;
temp/=10;
}
cout<<"Number was:"<<num<<endl;
cout<<"Reverse is:"<<rev<<endl;
if(num==rev)
cout<<"So, number is Palindrome";
else
cout<<"So, number is not Palindrome";
getch();
}
//Output:
Enter a number 343
Number was: 343
Reverse is: 343
So, number is Palindrome

### Working:

Flow of a program:

## Palindrome Number Using Function

Functions are used to perform certain actions, and they are important for reusing code: Define the code once and use it many times.

And, this is a another method to check whether it is palindrome or not i.e. by function

Note: Always remember that execution starts from the main body only.

### Example:

#include<iostream.h>
#include<conio.h>
int palindrome(int num)
{
int rev=0,rem,temp;
temp=num;
while(temp>0)
{
rem=temp%10;
rev=rev*10+rem;
temp=temp/10;
}
if(rev==num)
cout<<"Number is Palindrome";
else
cout<<"Number is not Palindrome";
return 0;}
int main(){
int n;
cout<<"enter any number:=";
cin>>n;
palindrome(n);
getch();
return 0;
}
//Output:
enter any number:=345
Number is not Palindrome

## Working:

Flow of a program:

Well, I hope it really helped you to know C++ better.

Attention readerâš  Donâ€™t stop learning now.

Just stay with us to get more such exciting codes to explore more in C++.