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,
171 is an armstrong number since 3**3+7**7+1**1= 371.
i have try but not succed.kindly help me .
here is what i did :
int main()
{
int a,b,n,s=0;
printf("enter no");
scanf("%d",&n);
b=s;
while(n>10)
{
a=n%10;
s=s+(a*a*a);
n=n/10;
}
s=s+(n*n*n);
if(b==s)
printf("armstro ng number\n");
return 0;
}
the cubes of its digits is equal to the number itself. for example,
171 is an armstrong number since 3**3+7**7+1**1= 371.
i have try but not succed.kindly help me .
here is what i did :
int main()
{
int a,b,n,s=0;
printf("enter no");
scanf("%d",&n);
b=s;
while(n>10)
{
a=n%10;
s=s+(a*a*a);
n=n/10;
}
s=s+(n*n*n);
if(b==s)
printf("armstro ng number\n");
return 0;
}
Comment