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 | ATotal is set to 0 inside the loop, so it is reset every time round and the running sum is lost. It should be set to 0 once before the loop. | |
| 2Total ← Total + Value | BSets the running total to zero before the loop starts, so the sum begins from nothing | |
| 3Totalling adds the value itself each time, but counting adds 1 each time | CAdds the current value to the running total inside the loop | |
| 4The total is output once after the loop has finished, not inside it | DENDFOR OUTPUT Total | |
| 5FOR Index ← 1 TO 5 Total ← 0 Total ← Total + Value NEXT Index | EThis adds 1 each time, which is counting, not totalling. It should add the value: Total ← Total + Value. | |
| 6FOR Index ← 1 TO 5 Total ← Total + 1 NEXT Index | FCount ← Count + 1 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Total ← Total + Value — Totalling keeps a running sum. Set Total to 0 before the loop, add each Value to Total inside the loop, then output Total after the loop. Counting adds 1 each time instead of the value.Total ← 0
FOR Index ← 1 TO 5
INPUT ValueFOR Index ← 1 TO 5
INPUT Value
Total ← Total + Value Total ← Total + Value
NEXT Index
OUTPUT TotalFOR Index ← 1 TO 5
INPUT Value
Count ← Count + 1FOR Index ← 1 TO 5
INPUT Value
Total ← Total + Value