ARMSTRONG NUMBER

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

Comments

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