Declaring and using a 2D array
Declares a 2D array of characters with 3 rows and 3 columns. Reach one element with a row index then a column index, e.g. NoughtsAndCrosses[2,3] ← 'X'.
Understanding Declaring and using a 2D array in IGCSE Computer Science Paper 2
What it does: The two index ranges 1:4 and 1:5 give 4 rows and 5 columns, which is how a 2D array is declared. For each row the inner loop runs through all the columns, so every element is reached by its row index and column index. The first range gives the row indices (lower:upper). The second range gives the column indices. The data type comes after OF. 3 rows x 3 columns = 9 elements. Do not add the two sizes together. The row index must be between 1 and 3. Row 4 is outside the declared range, so [4,1] does not exist.
Common mistakes: The inner loop is controlled by Col, so it must end with NEXT Col. NEXT Row belongs to the outer loop on the last line. The line should be ' NEXT Col'. A 2D array needs two index ranges, one for rows and one for columns. ARRAY[1:3] only declares a 1D array. It should be ARRAY[1:3, 1:3] OF CHAR.
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 176–187) and word search (Modules 166–187).
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
DECLARE NoughtsAndCrosses : ARRAY[1:3, 1:3] OF CHARFill in the Blanks
Spot the Error
Student with a class code? Join your class →