Using variables as indexes in a 2D array
Uses two variables as the row and column indexes, so one statement can reach any element of a 2D array. Both variables must stay within their bounds.
Understanding Using variables as indexes in a 2D array in IGCSE Computer Science Paper 2
What it does: Row and Column hold 2 and 3, so the assignment writes 'O' into Grid[2, 3] without typing the numbers inside the brackets. Row is 4, but the declared row bounds are 1 to 3, so the index is out of range and the statement would fail. The first index is the row and the second is the column. So Grid[Row, Column] with Row 2 and Column 3 is row 2, column 3. A 2D array needs two indexes. Grid[Row, Column] gives one variable for the row and one for the column. One statement with one value for each index writes to exactly one element. It does not fill a whole row.
Common mistakes: A 2D array needs two indexes. Grid[Row] gives only the row. It should be Grid[Row, Column] ← 'O'. A value is stored in a variable with the assignment arrow ←, not =. It should be Column ← 4, so Column can be used as the column index.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 469–478) and word search (Modules 459–478).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
Grid[Row, Column]Fill in the Blanks
Spot the Error
Student with a class code? Join your class →