Working out how many elements a 2D array holds
The total number of elements in a 2D array. Each dimension holds upper - lower + 1 values, so ARRAY[1:3, 1:3] holds 3 * 3 = 9 and ARRAY[1:30, 1:4] holds 30 * 4 = 120.
Understanding Working out how many elements a 2D array holds in IGCSE Computer Science Paper 2
What it does: Multiplying the size of the two dimensions gives the total number of elements in the 2D array. Counting from the lower bound to the upper bound includes both ends, so you add 1 after subtracting. For 1:30 this is 30 - 1 + 1 = 30. Rows: 3 - 1 + 1 = 3. Columns: 3 - 1 + 1 = 3. Total = 3 * 3 = 9. 30 rows * 4 columns = 120. You multiply the dimensions, you do not add them. Upper - lower + 1 = 4 - 0 + 1 = 5. The 0 counts as an index.
Common mistakes: The number of elements is rows multiplied by columns, not added. It should be Total ← Rows * Cols, which gives 3 * 3 = 9. Each dimension holds upper - lower + 1 values. The +1 is missing, so Rows would be 29. It should be Rows ← 30 - 1 + 1, which gives 30.
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
rows * columnsFill in the Blanks
Spot the Error
Student with a class code? Join your class →