C++ Palindrome number program

#include <iostream>
using namespace std;

int main()
 {
int sumStore=0,num,rem,palindrome,num1;
cout<<"Enter a number ";
cin>>num;
palindrome=num;
num1=num;
//loop to check every digit of number Entered
while(num!=0)
   {
      rem=num%10;
      //to store number
      sumStore=(sumStore*10)+rem;
      num=num/10;

   }
   //to check Entered number is palindorme or not
   if(sumStore==palindrome)
   {
      cout<<"The Number "<<num1<<" is Palindrome"<<endl;
   }
   else
   {
      cout<<"The Number "<<num1<<" is not Palindrome"<<endl;

   }

return 0;
}

No comments:

Post a Comment