Reading values into a 2D array with INPUT in nested loops
Inside nested FOR loops, this reads a typed value into one cell of a 2D array. The inner loop fills a whole row before the outer loop moves to the next row.
Understanding Reading values into a 2D array with INPUT in nested loops in IGCSE Computer Science Paper 2
What it does: The prompt uses the loop variables Student and Test, so the message changes each time to match the cell about to be filled by INPUT. The prompt must appear before the INPUT so the user knows what to type. If INPUT comes first, the program waits for a value with no prompt shown. The first three values fill Marks[1,1], Marks[1,2], Marks[1,3]. The 4th starts row 2, so it goes in Marks[2,1]. There is no 4th test in row 1. The inner loop controls the column. It finishes all of its columns for the current row before the outer loop changes the row.
Common mistakes: A FOR loop sets its counter with the assignment arrow, not =. The line should be FOR Student ← 1 TO 3. Marks is a 2D array, so each cell needs a row index and a column index. It should be INPUT Marks[Student, Test].
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
INPUT Marks[Student, Test]Fill in the Blanks
Spot the Error
Student with a class code? Join your class →