C++ Exercises: Check whether a given number is palindrome or not
C++ Numbers: Exercise-38 with Solution
Write a C++ program to check whether a given number is a palindrome or not.
Sample Solution:
C++ Code :
#include <iostream>
using namespace std;
int main()
{
int i,n1,r,s=0;
cout << "\n\n Check whether a given number is palindrome or not: \n";
cout << " -------------------------------------------------------\n";
cout << " Input a number: ";
cin>>n1;
for(i=n1;i>0; )
{
r=i % 10;
s=s*10+r;
i=i/10;
}
if(s==n1)
{
cout<<" "<<n1<<" is a Palindrome Number."<<endl;
}
else
{
cout<<" "<<n1<<" is a not Palindrome Number."<<endl;
}
}
Sample Output:
Check whether a given number is palindrome or not: ------------------------------------------------------- Input a number: 141 141 is a Palindrome Number.
Flowchart:

C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in C++ to find Narcissistic decimal numbers within a specific range.
Next: Write a program in C++ to print the first 20 numbers of the Pell series.
What is the difficulty level of this exercise?
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join