Q:

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

belongs to collection: Loop Programs In C ++Programming

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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;
}

 

Output:

Enter a number to check if it is a palindrome or not : 1331

1331 is a palindrome number

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program For Denomination of an Amount Using Wh... >>
<< C++ Program To Find The GCD And LCM Of Two Numbers...