Skip to main content
TO FIND WHETHER A NO. IS ARMSTRONG OR NOT IN C++
/* FOR EX. 153 = (1*1*1)+(5*5*5)+(3*3*3) */
# include <iostream.h>
# include <conio.h>
void main ()
{
clrscr();
int a,sum=0;
long int n,num;
cout<<"Enter the no. : ";
cin>>n;
num = n;
for(;n>0;)
{
a=n%10
sum=sum+(a*a*a);
n=n/10;
}
if(sum==num)
{
cout<<"IT IS AN ARMSTRONG NUMBER...";
}
else
{
cout<<"IT IS NOT AN ARMSTRONG NUMBER...";
}
getch();
}
Comments
Post a Comment