Palindrome Number

yogambika · September 23, 2020 · C++
#include <iostream>
using namespace std;
class number
{
    int n,t,rem,rev;
    public:
    void getdata();
    void check();
    void display();
};
void number::getdata()
{
    cout<<"\n____________PALINDROME NUMBER____________";
    cout<<"\n Enter the number:";
    cin>>n;
}
void number::check()
{
    t=n;
    rev=0;
    while(t!=0)
    {
        rem=t%10;
        rev=rev*10+rem;
        t=t/10;
    }
}
void number::display()
{
    cout<<"\n NUMBER:"<<n;
    if(rev==n)
    cout<<"\n"<<n<<" is a palindrome number:";
    else
    cout<<"\n"<<n<<" is not a palindrome number:";
}
main()
{
    int con;
    number n;
    do
    {
        n.getdata();
        n.check();
        n.display();
        cout<<"\n Do you want to continue?"<<"\n1.Yes\n2.No";
        cin>>con;
    }
    while(con==1);
}

Comments

Please sign up or log in to contribute to the discussion.