<<< Armstrong Number | Logical Flow of Code (LFoC)

nown = n;

    while(nown>0)

    {

        r = nown%10;

        c = r*r*r;

        sum = sum +  c;

        nown = nown/10;

    }

    if(sum == n)



Input: 153

Output: Armstrong


Armstrong number is a number that is equal to the sum of cubes of its digits. ... For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

Code Description for Armstrong Number: The provided code is an implementation of a program to check if a given number is an Armstrong number. An Armstrong number is a number that is equal to the sum of the cubes of its digits.

1. The code takes an integer input 'n', which is the number to be checked for being an Armstrong number.

2. A variable 'nown' is initialized with the value of 'n'. This variable will be used to extract and process the individual digits of the number.

3. The code enters a 'while' loop, which continues until 'nown' becomes zero.

4. Inside the loop, the last digit of 'nown' is extracted and stored in the variable 'r' using the modulo operator (%). This is done by taking 'nown % 10'.

5. The variable 'c' is then calculated as the cube of 'r' (i.e., 'r*r*r').

6. The value of 'c' is added to the 'sum' variable, which accumulates the sum of the cubes of each digit.

7. After processing the last digit, 'nown' is updated by removing the last digit from the number using integer division by 10 (i.e., 'nown = nown / 10'). This effectively removes the last digit from 'nown'.

8. The loop repeats the process until all digits have been processed.

9. Once the loop finishes, the 'sum' variable contains the sum of the cubes of each digit in the original number 'n'.

10. Finally, the code checks if the 'sum' is equal to the original number 'n'.

11. If 'sum' is equal to 'n', it means that the number 'n' is an Armstrong number. In this case, the code would typically print or return "Armstrong" as the output.

Note: The code assumes that 'n' is a positive integer. If the input number is negative or non-integer, additional input validation may be required to ensure the correctness of the program.