C++ Program to Check Whether the Given number is palindrome or not.
A Palindrome Number is a number whose reverse is same as itself i.e. when the given number is reversed then it will not effect the number and number will remain the same.
For Eg :- 121, 1441, 252 are palindrome numbers.
Now Lets see the C++ program to check whether the Given number is palindrome or not.
//Check whether the number is palindrome or not #include<iostream> using namespace std; int main(){ int n, temp, sum=0; cout << "Enter the Number: "; cin >> n; temp = n; while(n>0){ sum = (sum*10) + n%10; n/=10; } if(temp == sum){ cout << temp << " is a Palindrome number"; } else{ cout << temp << " is not a palindrome number"; } return 0; }
Output :-
Enter the Number: 5775 5775 is a Palindrome number Enter the Number: 1234 1234 is not a palindrome number