DESCRIPTION-: THIS PROGRAM FINDS THE ARMSTRONG NUMBER.
ARMSTRONG NUMBER IS ONE IN WHICH THE SUM
OF THE CUBES OF THE DIGITS IS EQUAL TO THE
NUMBER ITSELF.
FOR EXAMPLE 153
1^3+5^3+3^3=153
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,m,rem,sum=0;
cout<<"enter the required number";
cin>>n;
m=n;
while(m>0)
{
rem=m%10;
m=m/10;
sum=sum+rem*rem*rem;
}
if(sum==n)
{
cout<<"number is armstrong";
}
else
{
cout<<"number is not armstrong";
}
getch();
}
ARMSTRONG NUMBER IS ONE IN WHICH THE SUM
OF THE CUBES OF THE DIGITS IS EQUAL TO THE
NUMBER ITSELF.
FOR EXAMPLE 153
1^3+5^3+3^3=153
PROGRAM-:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,m,rem,sum=0;
cout<<"enter the required number";
cin>>n;
m=n;
while(m>0)
{
rem=m%10;
m=m/10;
sum=sum+rem*rem*rem;
}
if(sum==n)
{
cout<<"number is armstrong";
}
else
{
cout<<"number is not armstrong";
}
getch();
}
0 comments:
Post a Comment