Palindrome Using Class.cpp

Kali26 · September 23, 2020 · C++
#include <iostream>
using namespace std;
class palindromenumber
{
    int n,s,t,r;
    public:
    void getdata();
    void check();
};
void palindromenumber:: getdata()
{
    cout<<"\n Enter a number:";
    cin>>n;
}
void palindromenumber::check()
{
    t=n;
    s=0;
    while (n>0)
    {
        r=n%10;
        s=s*10+r;
        n=n/10;
    }
    if(s==t)
    cout<<"\n The given number is a palindrome";
    else
    cout<<"\n The given number is not a palindrome";
}


int main() 
{
    palindromenumber n;
    
    cout<<"\nCHECKING OF PALINDROMENUMBER OR NOT";
    cout<<"\n ••••••••••••••••••••••••••••••••••";
    n.getdata();
    n.check();
    return 0;
}

Comments

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