#include<stdio.h>
int main()
{
int num, sum = 0;
printf("Please enter a number: ");
scanf("%d",&num);
for (int i = num; i > 0;)
{
sum += (i % 10) * (i % 10) * (i % 10);
i = i / 10;
}
if ( sum==num)
printf("%d is an armstrong number.",num);
else
printf("%d is not an armstrong number.",num);
return 0;
}
int main()
{
int num, sum = 0;
printf("Please enter a number: ");
scanf("%d",&num);
for (int i = num; i > 0;)
{
sum += (i % 10) * (i % 10) * (i % 10);
i = i / 10;
}
if ( sum==num)
printf("%d is an armstrong number.",num);
else
printf("%d is not an armstrong number.",num);
return 0;
}
No comments:
Post a Comment