02/04/2016

C++ Program To Find Whether A Number Is Palindrome Or Not

#include <conio.h>
#include<iostream.h>
int main()
{
   int n, reverse = 0, temp;
 clrscr();
   cout<<"\n\tEnter a number to check if it is a palindrome or not: ";
   cin>>n;

   temp = n;

   while( temp != 0 )
   {
      reverse = reverse * 10;
      reverse = reverse + temp%10;
      temp = temp/10;
   }

   if ( n == reverse )
      cout<<n<<" is a palindrome number.\n";
   else
      cout<<n<<" is not a palindrome number.\n";
  getch();
   return 0;
}

http://www.programmingwithbasics.com/

http://www.programmingwithbasics.com/

Previous Post
Next Post

post written by:

0 Comments: