C Programming Code Examples C > Mathematics Code Examples Armstrong Numbers Between Two Integers Armstrong Numbers Between Two Integers In case of an Armstrong number of 3 digits, the sum of cubes of each digits is equal to the number itself. For example: 407 = 4*4*4 + 0*0*0 + 7*7*7 // 407 is an Armstrong number. #include <stdio.h> #include <math.h> int main() { int low, high, j, temp1, temp2, remainder, n = 0, result = 0; printf("Enter two numbers(intervals): "); scanf("%d %d", &low, &high); printf("Armstrong numbers between %d an %d are: ", low, high); for(j = low + 1; j < high; ++j) { temp2 = j; temp1 = j; // number of digits calculation while (temp1 != 0) { temp1 /= 10; ++n; } // result contains sum of nth power of its digits while (temp2 != 0) { remainder = temp2 % 10; result += pow(remainder, n); temp2 /= 10; } // checks if number j is equal to the sum of nth power of its digits if (result == j) { printf("%d ", j); } // resetting the values to check Armstrong number for next iteration n = 0; result = 0; } return 0; }