Pages

Tuesday, February 17, 2015

C Program check whether a number is palindrome or not


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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.