I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
#include <iostream>
using namespace std;
int main()
{
int num, i, rev;
//Reading a number from user
cout<<"Enter any number:";
cin>>num;
rev = num;
for(i=0; num>0; num=num/10)
{
i = i * 10;
i = i + (num%10);
}
//Checking if reverse number is equal to original num or not.
if(rev == i)
cout<< rev << " is a Palindrome Number.";
else
cout<< rev << " is not a Palindrome Number.";
return 0;
}
I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.
Result:
Enter any number:121
121 is a Palindrome Number.
need an explanation for this answer? contact us directly to get an explanation for this answer