Input | Process | Output |
---|---|---|
Ages of four boys | 1. Accept the ages of the four boys as input (e.g., age1, age2, age3, age4). | Total age of four boys. |
(e.g., age1, age2, age3, age4) | 2. Calculate the total age by adding all the ages together: total=age1+age2+age3+age4 | The average age of the boys. |
3. Calculate the average age by dividing the total age by 4: average=total/4 |
Explanation:
- The input consists of the ages of the four boys.
- The process involves two steps: first, calculating the total age by adding all four ages together, and second, finding the average by dividing the total by 4 (since there are 4 boys).
- The output will display both the total age and the average age.
Example:
If the ages are 12, 14, 16, and 18, the program would output:
- Total age = 12 + 14 + 16 + 18 = 60
- Average age = 60 / 4 = 15