Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.
Example:
371 = (3*3*3)+(7*7*7)+(1*1*1)
where: (3*3*3)=27
(7*7*7)=343
(1*1*1)=1
So: 27+343+1=371
#include<stdio.h>
#include<conio.h>
int main()
{
int n,r,sum=0,t;
printf("enter any number");
scanf("%d",&n);
t=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(t==sum)
printf("%d is armstrong number ",t);
else
printf("%d is not armstrong number",t);
getch ();
return 0;
}
enter any number153
153 is armstrong number
--------------------------------
Process exited after 4.585 seconds with return value 0
Press any key to continue . . .