/*Armstrong or Not*/
#include<stdio.h>
main()
{
int n,r,c,sum=0,temp;
printf("Enter number:");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
c=r*r*r;
sum=sum+c;
n=n/10;
}
n=temp;
if(n==sum)
printf("ArmStrong Number");
else
printf("Not ArmStrong Number");
}
Example:
153 = 1^3 + 5^3 + 3^3
=1 + 125 + 27
=153 / / It is Armstrong
Other Related Topic