Challenge 30

📊

Averages

Open in Code Editor or Copy Instructions
...solutions at bottom of page...

Ask the user to enter 5 numbers and calculate the mean. You should ensure you can do this with each of the 3 types of loops (count controlled/FOR, pre-conditional/WHILE, post-conditional/REPEAT...UNTIL)

Examples:

Inputs of 1, 2, 3, 4, 5 would return 3

Inputs of 0.1, 0.2, 0.3, 0.4, 0.5 would return 0.3

Inputs of -2, -1, 0, 1, 2 would return 0

Extension:

Have your program also output the min, max, total and range. If you are feeling adventurous, also try the mode, median, standard deviation etc

Solutions

IGCSE 0478 / O-Level 2210 A-Level 9618