Monday 27 August 2012

Armstrong Number in c++ cplus plus(cpp) with source code

How to write A Program for  Armstrong Number.
before to start this program just get the definition of Armstrong number .
like (153=1*1*1+5*5*5+3*3*3).left side value is equal to the right side value then number is called Armstrong number.else number is not Armstrong number
class arm
{
int n;
public: arm();
void display();
};
void arm::arm()
{
cout<<"\n a=";
cin>>n;
}
void arm::display()
{
int sum=0,r;
int a=n;
while(n>0)
{
r=n%10;
n=n/10;
sum=sum+(r*r*r);
}
if(a==sum)
cout<<"armstrong";
else cout<<"not armstrong";
}
void main()
{
arm ob;
clrscr();
ob.display();
getch();
}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: