Question 1
1 markThis algorithm should output the total of five marks, but a statement is missing from the start.
FOR Index ← 1 TO 5
INPUT Mark
Total ← Total + Mark
NEXT Index
OUTPUT TotalState the missing statement.
Model answer
Total ← 0
Explanation
A total must be initialised before it is used. Without Total ← 0, the first time Total ← Total + Mark runs, Total has no value. The initialisation must be before the loop, not inside it, or the total would be reset each time.
Mark scheme
-
1 mark
Total ← 0 (before the loop)