Monday, November 14, 2011

Palindrome Number or Not

Wap to check whether  the input number of 3 digit is palindrome or not.


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,r=0,t,a;
cout<<"enter number";
cin>>n;
a=n;
while(n>0)
{
t=n%10;
n/=10;
r=r*10+t;
}
if (r==a)
cout<<"num is palindrome";
else
cout<<"not a palindrome";
getch();
}

****************
OUTPUT:
enter number 131
num is palindrome
****************

No comments:

Post a Comment