PALINDROME Number

Muthumari_B · updated October 03, 2021 · C++
// PALINDROME Number checking program using class 
 
 
#include <iostream>
using namespace std;
class pali
{
    int n,t,rem,sum=0;
    public:
    void getdata();
    void check();
};
void pali::getdata()
{
    cout<<"\n PALINDROME  Number checking program"<<endl;
    cout<<"\n Enter a Number : ";
    cin>>n;
    cout<<n<<endl;
}
void pali:: check()
{
    t=n;
    while(t!=0)
    {
        rem=t%10;
        sum=sum*10+rem;
        t=t/10;
    }
    if(sum==n)
    {
        cout<<"\n"<<n<<" is a PALINDROME Number."<<endl;
    }
    else
    {
        cout<<"\n"<<n<<" is Not a PALINDROME Number."<<endl;
    }
}   
int main()
{
    pali n;
    n.getdata();
    n.check();
    return 0;
}

Comments

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