Tuesday, 3 September 2013

C++ Program For Amsrong Number


#include<conio.h>
#include<stdio.h>
  class amstrong
    {
      int n,a,b,c;
  public:
      void input();
      void output();
    };

       void amstrong::input()
        {
cout<<"Enter the no ";
cin>>n;
        }
       void amstrong::output()
        {
c=0,b=n;
  while(n>0)
  {
   a=b;
   c=c+(a*a*a);
   n=n/10;
           }
if(c==b)
{
 cout<<"the no is amstrong";
}
else
{
 cout<<"the no is not amstrong";
}
        }

 void main()

 {
  clrscr();
  amstrong a;
  a.input();
  a.output();
  getch();
 }

No comments:

Post a Comment