luc029.c (763B)
1 /* Write a program to print out all Armstrong numbers between 100 2 and 500. If sum of cubes of each digit of the number is equal to the 3 number itself, then the number is called an Armstrong number. For 4 example, 153 = (1 * 1 * 1) + (5 * 5 * 5) + (3 * 3 * 3) */ 5 /* Let Us C, Chap- 5, Page - 87, Qn No.: B(b) */ 6 7 #include <stdio.h> 8 #include <math.h> 9 int main() 10 { 11 int num = 100, temp1, temp2, res; 12 printf("Armstrong numbers between 100 and 500 :"); 13 while (num <= 500) 14 { 15 temp1 = num; 16 res = 0; 17 while (temp1 != 0) 18 { 19 temp2 = temp1 % 10; 20 res = res + pow(temp2, 3); 21 temp1 = temp1 / 10; 22 } 23 if (num == res) 24 printf(" %d", num); 25 num++; 26 } 27 return 0; 28 }