Program to check a number is palindrome or not :-
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int dup,num,rem,rev=0;
cout<<"Enter a Number to check it is Palindrome or not :\n ";
cin>>num;
dup=num;
for(num;num>0;num=num/10)
{
rem=num%10;
rev=rev*10+rem;
}
if(rev==dup)
{
cout<<setw(4)<<dup<<endl;
cout<<"\nThe given number is a palidrome.";
}
getch();
}
No comments:
Post a Comment