A positive integer is called an Armstrong number (of order n) if
abcd... = an + bn + cn + dn + ...
In the case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example, 153 is an Armstrong number because
153 = 1*1*1 + 5*5*5 + 3*3*3
Example: Check Armstrong Number of 3 Digits
Output
Enter a positive integer: 371 371 is an Armstrong number.
In the program, we iterate through the while loop until originalNum is 0.
In each iteration of the loop, the cube of the last digit of orignalNum is added to result.
remainder = originalNum % 10;
result += remainder * remainder * remainder;
And, the last digit is removed from the orignalNum.
When the loop ends, the sum of the individual digit's cube is stored in result.
Example: Check Armstrong Number of n Digits
Output
Enter an integer: 1634 1634 is an Armstrong number.
In this program, the number of digits of the entered number is calculated first and stored in n.
And, the pow() function computes the power of individual digits in each iteration of the while loop.