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 | |
|---|---|---|
| 1FOR Index ← 1 TO 30 Names[Index] ← "" NEXT Index | ADisplays every element of the Names array in turn, from element 1 to element 30 | |
| 2FOR Index ← 1 TO 30 OUTPUT Names[Index] NEXT Index | BSets every element of the Names array to an empty string, one element at a time | |
| 3A FOR loop can store a value typed by the user in every element of an array | CThe loop bounds do not match the array. The array runs from 1 to 30, so starting at 0 refers to an element that does not exist and the loop runs 31 times. | |
| 4A FOR loop can add up every element of an array by using the counter as the index | DFOR Index ← 1 TO 30 INPUT Names[Index] NEXT Index | |
| 5FOR Index ← 1 TO 30 OUTPUT Names[30] NEXT Index | EThe index is fixed at 30 instead of using the counter Index, so the loop outputs the last element 30 times and never visits the others. | |
| 6FOR Index ← 0 TO 30 INPUT Names[Index] NEXT Index | FFOR Index ← 1 TO 30 Total ← Total + Marks[Index] NEXT Index |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
FOR Index ← 1 TO 30 — Uses the loop counter Index as the array index, so Names[Index] visits every element in turn. Each one can be read, changed, input, output or totalled.FOR Index ← 1 TO 30
Names[Index] ← ""
NEXT IndexFOR Index ← 1 TO 30
INPUT Names[Index]
NEXT IndexFOR Index ← 1 TO 30
OUTPUT Names[Index]
NEXT IndexFOR Index ← 1 TO 30
Total ← Total + Scores[Index]
NEXT IndexFOR Index ← 1 TO 30
OUTPUT Names[Index]
NEXT Index