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 Row ← 1 TO 3 | AThe OUTPUT line gives only one index. A 2D array needs both the row and the column, so it should be Grid[Row, Column]. | |
| 2OUTPUT Grid[2, Column] | BInside a loop over Column, this displays every element of row 2 only. | |
| 3The inner loop moves across the columns, and OUTPUT inside it displays one element each time round. | CThe outer loop: it moves through each row of the 2D array, one row at a time. | |
| 4To display only column 3 of a 2D array, loop through the rows and keep the column index fixed. | DFOR Column ← 1 TO 4 OUTPUT Grid[Row, Column] NEXT Column | |
| 5FOR Row ← 1 TO 3 FOR Column ← 1 TO 4 OUTPUT Grid[Row] NEXT Column NEXT Row | EThe outer loop has no NEXT Row, so it is never closed. NEXT Row must be added after NEXT Column. | |
| 6FOR Row ← 1 TO 3 FOR Column ← 1 TO 4 OUTPUT Grid[Row, Column] NEXT Column | FFOR Row ← 1 TO 3 OUTPUT Grid[Row, 3] NEXT Row |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
OUTPUT Name[Row, Column] — Placed inside nested FOR loops (outer loop for rows, inner loop for columns), this line displays each element of a 2D array once, in row order.FOR Row ← 1 TO 3
FOR Column ← 1 TO 4
OUTPUT Grid[Row, Column]FOR Row ← 1 TO 3
FOR Column ← 1 TO 4
OUTPUT Grid[Row, Column]FOR Row ← 1 TO 3
OUTPUT Grid[Row, 2]
NEXT RowOUTPUT Grid[Row, Column]
NEXT Column
NEXT RowFOR Row ← 1 TO 3
FOR Column ← 1 TO 4
OUTPUT Seats[Row, Column]