
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.
#include <stdio.h>
int main()
{
int n,t,s,r;
printf("\nEnter the Number ");
scanf(" %d", &n);
t=n;
s=0;
while(n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(t==s)
{
printf("\n The given Number %d is an Amstrong Number" , t);
}
else
{
printf("\n The given Number %d is not an Amstrong Number" , t);
}
return 0;
}
Comments
Post a Comment