Totalling rows, columns and a whole 2D array
Adds each element to a running total inside nested loops. Set Total to 0 first: before the loops for a grand total, or inside the outer loop for each row or column total.
Understanding Totalling rows, columns and a whole 2D array in IGCSE Computer Science Paper 2
What it does: With Column in the outer loop, the inner loop moves down one column. Total is reset for each column and then adds every Row in that column. Total is never reset between rows, so it keeps growing. This gives a running total, not a row total.
Common mistakes: The indexes are the wrong way round. Mark[C, R] puts the column loop in the row position, and C goes up to 4 but there are only 3 rows. It should be Total ← Total + Mark[R, C]. The array has 4 columns, but this inner loop stops at 3. Each row total misses the last column. It should be FOR C ← 1 TO 4.
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
Total ← Total + Marks[Row, Column]Fill in the Blanks
Spot the Error
Student with a class code? Join your class →