Note: Polindrome is a number that is same if we reverse it. e.g: 151 reverse is 151
#include <iostream>
using namespace std;
int main()
{
int number, ans = 0, temp;
cout << "Enter a number: ";
cin >> number;
temp = number;
while( number != 0)
{
ans = ans*10;
ans = ans + number%10;
number = number/10;
}
if(ans == temp)
{
cout << "Number is polindrome.";
}
else
{
cout << "Number is not polindrome.";
}
system("pause");
}
#include <iostream>
using namespace std;
int main()
{
int number, ans = 0, temp;
cout << "Enter a number: ";
cin >> number;
temp = number;
while( number != 0)
{
ans = ans*10;
ans = ans + number%10;
number = number/10;
}
if(ans == temp)
{
cout << "Number is polindrome.";
}
else
{
cout << "Number is not polindrome.";
}
system("pause");
}