Still loading. This can take a moment on a slow connection.
Still loading. This can take a moment on a slow connection.
Fill a two-dimensional array with nested loops, and predict the value each cell is given and the order they are filled in.
StartThe program is about to run, from line 1.
| Row | 1 | 2 | 3 |
|---|---|---|---|
| 1 | Grid[1, 1]: no value yet | Grid[1, 2]: no value yet | Grid[1, 3]: no value yet |
| 2 | Grid[2, 1]: no value yet | Grid[2, 2]: no value yet | Grid[2, 3]: no value yet |
DECLARE Grid : ARRAY[1:2, 1:3] OF INTEGERDECLARE Row : INTEGERDECLARE Column : INTEGERFOR Row ← 1 TO 2 FOR Column ← 1 TO 3 Grid[Row, Column] ← Row * Column NEXT ColumnNEXT RowOUTPUT Grid[2, 3]| Row | — |
|---|---|
| Column | — |
Before a line runs, say what it will do: the value it stores, what it outputs, or whether a test is TRUE. Play waits for your answer.
After your first prediction, this says why it works.
Try what you found on the lesson’s 34 marked questions. Practise in Two-Dimensional Arrays
Key
A teaching interpreter for the pseudocode the 0478 syllabus writes. It runs a program a line at a time, and stops one that takes more than 2000 steps or outputs more than 200 lines. Names are not case-sensitive, as the syllabus says. An input is read as the data type its variable was declared with. Files are held in the page: each run starts from the files under Files, and nothing is saved. When a FOR loop ends, its counter keeps the last value it ran with.