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