4/01/2009

C++ Program To Check Whether The Given Number Is Palindrome Or Not


/* C++ Program To Check Whether The Given Number Is Palindrome Or Not */

#include <iostream>

using namespace std;

int main()
{
    int number,rev=0;
      cout<<"Enter The Number:"<<endl;
        cin>>number;
      int temp=number;
        while(number>0)
        {
            int rem=number%10;
            number=number/10;
            rev=(rev*10)+rem;
        }
        if(rev==temp)
            cout<<"The Given Number "<<temp<<" Is A Palindrome Number."<<endl;
        else
            cout<<"The Given Number "<<temp<<" Is Not A Palindrome Number."<<endl;


    return 0;
 }
Out Put:
Enter The Number:
121
The Given Number 121 Is A Palindrome Number.

No comments:

Post a Comment