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 FOR Column ← 1 TO 3 | AFOR Row ← 1 TO 3 FOR Column ← 1 TO 3 Board[Row, Column] ← ' ' NEXT Column NEXT Row | |
| 2Board[Row, Column] ← ' ' | BNEXT Column NEXT Row | |
| 3The inner loop must be closed first, so its NEXT comes before the NEXT of the outer loop | CSets the current element, chosen by the row and column loop variables, to a space | |
| 4A complete nested loop that sets every element of a 3 by 3 array to a space | DThe Row variable is used for both indexes. The second index should be Column, so only the diagonal elements are set. | |
| 5FOR Row ← 1 TO 3 FOR Column ← 1 TO 3 Board[Row, Column] ← ' ' NEXT Row NEXT Column | EOuter loop steps through the rows; the inner loop steps through the columns for each row | |
| 6FOR Row ← 1 TO 3 FOR Column ← 1 TO 3 Board[Row, Row] ← ' ' NEXT Column NEXT Row | FThe NEXT statements are in the wrong order. The inner loop (Column) must be closed first, then the outer loop (Row). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
nested FOR loop — A FOR loop for the columns placed inside a FOR loop for the rows. The inner loop runs fully for each row, so every element of a 2D array is visited and given a value.FOR Row ← 1 TO 3
FOR Column ← 1 TO 3
Board[Row, Column] ← ' 'FOR Column ← 1 TO 3
Board[Row, Column] ← ' '
NEXT ColumnFOR Row ← 1 TO 3
FOR Column ← 1 TO 3
Board[Row, Column] ← ' 'FOR Column ← 1 TO 3
Board[Row, Column] ← ' '
NEXT Column Board[Row, Column] ← ' '
NEXT Column
NEXT Row