C Programming Code Examples C > Mathematics Code Examples Check Armstrong Number of n digits Check Armstrong Number of n digits 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 number, originalNumber, remainder, result = 0, n = 0 ; printf("Enter an integer: "); scanf("%d", &number); originalNumber = number; while (originalNumber != 0) { originalNumber /= 10; ++n; } originalNumber = number; while (originalNumber != 0) { remainder = originalNumber%10; result += pow(remainder, n); originalNumber /= 10; } if(result == number) printf("%d is an Armstrong number.", number); else printf("%d is not an Armstrong number.", number); return 0; }