A grid-based adventure game uses a 2D array named board to store the layout of a 3×3 3 \times 3\,3×3 playing area. The value 7 is used to represent the "golden key" on the board.
foundRow = -1
foundCol = -1
for r = 0 to 2
for c = 0 to 2
if board[r, c] == 7 then
foundRow = r
foundCol = c
endif
next c
next r
| Column 0 | Column 1 | Column 2 | |
|---|---|---|---|
| Row 0 | 1 | 3 | 2 |
| Row 1 | 5 | 7 | 4 |
| Row 2 | 8 | 0 | 6 |
State the purpose of the program code in Figure 1.
298 exam-style questions on AQA GCSE Computer Science Programming concepts. Each one has a worked solution and a mark scheme showing where the marks go.