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 | |
|---|---|---|
| 1IF Grid[Row, Column] = Wanted THEN | AIF Grid[Row, Column] = " " THEN Empty ← TRUE | |
| 2FoundRow ← Row | B<- is the assignment arrow, so it cannot be used to compare values. Use = to compare: IF Grid[Row, Column] = Wanted THEN | |
| 3To count how many times a value appears in a 2D array, add 1 to a counter each time an element matches | CCompares the element at the current row and column with the wanted value inside nested loops | |
| 4To check a grid for an empty cell, compare each element with the empty marker such as a space | DStores the row number where the wanted value was found | |
| 5IF Grid[Row, Column] <- Wanted THEN | EA 2D array element needs both indexes. Write Grid[Row, Column] so one cell is compared with Wanted | |
| 6IF Grid[Row] = Wanted THEN | FIF Grid[Row, Column] = Wanted THEN Count ← Count + 1 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IF Grid[Row, Column] = Wanted THEN — Inside nested FOR loops, this compares each 2D array element with the wanted value; when it matches, store Row and Column as FoundRow and FoundColumn.FOR Column ← 1 TO 3
IF Grid[Row, Column] = Wanted THENIF Grid[Row, Column] = Wanted THEN
FoundRow ← Row
FoundColumn ← ColumnIF Grid[Row, Column] = Wanted THEN
Count ← Count + 1
ENDIFFOR Column ← 1 TO 3
IF Grid[Row, Column] = "" THEN
Empty ← TRUEIF Grid[Row, 1] = "X" AND Grid[Row, 2] = "X"
AND Grid[Row, 3] = "X" THEN