Reading values into an array with INPUT in a loop
Inside a FOR loop, INPUT Name[Index] stores each value the user types into the next array element, because Index changes every time the loop repeats.
Understanding Reading values into an array with INPUT in a loop in IGCSE Computer Science Paper 2
What it does: The OUTPUT line tells the user what to type, and INPUT stores the answer in the element at the current Index. The INPUT must be inside the loop so it repeats for every index. Outside the loop it would only run once. An INTEGER array can only hold whole numbers. Text such as seventy-two is a STRING and does not fit. An array has a fixed length and bounds. The loop must run from 1 to 10 to match the declaration. An array element is chosen by its index, so without [Index] the typed value has no element to go into.
Common mistakes: The INPUT has no index, so it does not say which element stores the value. It should be INPUT StudentNames[Index] so each value goes into the next element. The prompt text is missing its closing quote mark. It should be OUTPUT "Enter a mark" so the prompt displays before each INPUT.
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 459–468) 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 Name[Index]Fill in the Blanks
Spot the Error
Student with a class code? Join your class →