Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1Total ← 0 | AFOR Index ← 1 TO 10 Total ← Total + Marks[Index] NEXT Index | |
| 2Total ← Total + Marks[Index] | BTotal was never set to 0 before the loop, so it starts with an unknown value and the final answer will be wrong. Add Total ← 0 before the FOR. | |
| 3Work out the average of the elements after the loop has finished adding them all up | CAdds the element at the current index to the running total on each pass of the loop | |
| 4Total all 10 elements of an array using a count-controlled loop | DSets the running total to zero before the loop starts, so the sum begins from a clean value | |
| 5FOR Index ← 1 TO 10 Total ← 0 Total ← Total + Marks[Index] NEXT Index | EAverage ← Total / 10 | |
| 6FOR Index ← 1 TO 10 Total ← Total + Marks[Index] NEXT Index OUTPUT Total | FTotal is reset to 0 inside the loop, so it is wiped on every pass and only the last mark is kept. Set Total ← 0 once before the loop. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Total ← Total + Marks[Index] — Adds the current element to the running total on each loop pass. Set Total ← 0 before the loop first, or the answer will be wrong. Divide by the number of elements for the average.Total ← 0
FOR Index ← 1 TO 5
Total ← Total + Marks[Index]Total ← 0
FOR Index ← 1 TO 5
Total ← Total + Marks[Index]FOR Index ← 1 TO 5
Total ← Total + Marks[Index]
NEXT IndexOUTPUT Total
Average ← Total / 5
OUTPUT AverageDECLARE Marks : ARRAY[1:10] OF INTEGER
FOR Index ← 1 TO 10
Total ← Total + Marks[Index]