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();
 }

Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments:

Post a Comment