Sunday, 7 April 2013

Palindrome program in c++


#include<iostream.h>
#include<conio.h>
main()
{
 int n,num,rev=0,digit;
 cout<<"enter a positve number =";
 cin>>num;
 n=num;
 while(num!=0)
 {
  digit=num%10;
  rev=rev*10+digit;
  num=num/10;
  }
  cout<<"the reverse of the number ="<<rev<<endl;
  if(n==rev)
  cout<<"the given number is palindrome";
  else
cout<<"the given number is not palindrome";
getch();
 }

No comments:

Post a Comment