#include <conio.h>
#include<iostream.h>
int main()
{
int n, reverse = 0, temp;
clrscr();
cout<<"\n\tEnter a number to check if it is a palindrome or not: ";
cin>>n;
temp = n;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if ( n == reverse )
cout<<n<<" is a palindrome number.\n";
else
cout<<n<<" is not a palindrome number.\n";
getch();
return 0;
}
#include<iostream.h>
int main()
{
int n, reverse = 0, temp;
clrscr();
cout<<"\n\tEnter a number to check if it is a palindrome or not: ";
cin>>n;
temp = n;
while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if ( n == reverse )
cout<<n<<" is a palindrome number.\n";
else
cout<<n<<" is not a palindrome number.\n";
getch();
return 0;
}
0 Comments: