Armstrong Number

M_deepakkumar · September 23, 2020 · C++
#include <iostream>
using namespace std;
class arm
{
    int r,g,rem,y;
    public:
    void getdata();
    void checking();
};
   void arm::getdata()
   {
       cout<<"Enter the Number"<<endl;
       cin>>r;
   } 
   void arm::checking()
   {
       g=r;
       y=0;
       while(g!=0)
    {
        rem=g%10;
        y=rem+rem+rem;
        g=g/10;
    }
   if(y==r)
   cout<<r<<" "<< "is not a armstrong number";
   else
   cout<<r<<" "<< "is a armstrong number";
   } 
   int main()
   {
       arm r;
       r.getdata();
       r.checking();
       return 0;
   } 

Comments

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