C++ Program to Find a Number is Palindrome or Not

Palindrome number is a number that can be same as for the reversed number. For example, 121 is a palindrome number because the reverse number of 121 is also121.

We can also find a string whether it is a palindrome or not. When the reversed string is same for the original string then it is called palindrome string.

C++ Program to Find a Number is Palindrome or Not

C++ Program to Find a Number is Palindrome or Not

Program code of Palindrome Program in C++

#include <iostream>  
using namespace std;  
int main()  
{  
  int n,r,sum=0,temp;    
  cout<<"Enter the Number=";    
  cin>>n;    
 temp=n;    
 while(n>0)    
{    
 r=n%10;    
 sum=(sum*10)+r;    
 n=n/10;    
}    
if(temp==sum)    
cout<<"Number is Palindrome.";    
else    
cout<<"Number is not Palindrome.";   
  return 0;  
}  

If else condition uses to display the output whether the number is palindrome or not. Initially the input number is assign to variable. The reverse matrix is assign to the another variable.

The reverse number and the original number is same then the given number is palindrome number. Otherwise, the number is not palindrome.

Read Also : Find Transpose of a Matrix in C++

Output

The reverse number of 121 is same so it is palindrome. The reverse number of 113 is not same so it is not palindrome.

Enter the Number=121   
Number is Palindrome.	
Enter the number=113  
Number is not Palindrome.

Final Words

I hope this article helps you to Find a Number is Palindrome or Not in C++ Program. If you face any issues please let me know via the comment section. Share this article with other C++ program developers via social networks.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment