This pseudocode reads 5 numbers into an array, adds them, and finds the average. I’ll explain each line in simple English.
Step 1 — Setting and declaration
-
DECLARE Numbers : ARRAY[1:5] OF INTEGER
This creates a list called Numbers that can hold 5 whole numbers. Think of it as 5 boxes labelled 1 to 5. -
DECLARE Total, Average : REAL
This creates two variables: Total (to add numbers) and Average (to store the result). We useREALso the average can be a decimal if needed. -
SET Total ← 0
Start Total at 0 because nothing has been added yet.
Step 2 — Input
-
FOR Count ← 1 TO 5…NEXT Count
This is a loop that runs 5 times. Each time,Counttakes values 1, 2, 3, 4, then 5. -
Inside the loop:
-
OUTPUT "Enter number ", Count, ": "
Shows a message asking the student to enter the number for positionCount. -
INPUT Numbers[Count]
The number typed by the student is stored in theCount-th box of the Numbers array. For example, if the student types 7 whenCount= 3, thenNumbers[3]becomes 7.
-
Step 3 — Process
-
FOR Count ← 1 TO 5…NEXT Count
Another loop that goes through each of the 5 numbers again. -
Total ← Total + Numbers[Count]
On each pass, add the current array item to Total. After the loop Total equals the sum of all five numbers. -
SET Average ← Total / 5
Divide the sum by 5 to get the average and store it in Average.
Step 4 — Output
-
OUTPUT "The total is: ", Total
Shows the total (sum) to the student. -
OUTPUT "The average is: ", Average
Shows the average to the student.
Quick example
If the student enters: 2, 4, 6, 8, 10
-
Total = 2+4+6+8+10 = 30
-
Average = 30 / 5 = 6
Tip for practice
Write the code and run through the example in your notebook: list the array slots, fill them with numbers, show how Total changes each loop, and then calculate the average. This makes the logic clear and easy to remember.
