/**************************************************************
* Program to find the Armstrong numbers between 100 and 999
***************************************************************/
#include <stdio.h>
int main()
{
int num, sum, rem;
for(int n = 100; n < 999; n++)
{
num = n;
sum = 0;
while(num != 0)
{
rem = num % 10; // get the last digit | sum += rem * rem * rem; // cube the remainder and add it to the sum | num = num / 10; // remove the last digit
}
if(n == sum)
{
printf("%d is an Armstrong number\n", n);
}
}
return 0;
}