#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
unsigned long n,num,d,rev=0;
cout<<"\n Enter a number : ";
cin>>n;
num=n;
do
{
d=n%10;
rev=(rev*10)+d;
n=n/10;
}
while(n!=0);
if(num==rev)
cout<<"\n\t Number is Palindrome";
else
cout<<"\n\t Number is not Palindrome";
getch();
}
Output

#include<conio.h>
void main()
{
clrscr();
unsigned long n,num,d,rev=0;
cout<<"\n Enter a number : ";
cin>>n;
num=n;
do
{
d=n%10;
rev=(rev*10)+d;
n=n/10;
}
while(n!=0);
if(num==rev)
cout<<"\n\t Number is Palindrome";
else
cout<<"\n\t Number is not Palindrome";
getch();
}
Output
No comments:
Post a Comment