Count-controlled loop: FOR … TO … NEXT
A count-controlled loop. It repeats the indented statements once for each value of Index, from 1 up to 30, going up by 1 each time. NEXT Index closes the loop.
Understanding Count-controlled loop: FOR … TO … NEXT in IGCSE Computer Science Paper 2
What it does: The OUTPUT line is indented between FOR and NEXT, so it is the loop body and runs once for each value of Index. Index starts at 1, increases by 1 each time round and stops after 30, which gives 30 repeats. Cambridge pseudocode writes the start with the assignment arrow: FOR Index ← 1 TO 30. There is no DO. A FOR ... TO ... NEXT loop repeats a set number of times, so it is count-controlled. A WHILE loop repeats while a condition is true. The loop variable name after NEXT must match the one after FOR, otherwise the loop is not closed correctly.
Common mistakes: The array index must use the loop variable Index, which changes each time round. Count is not the loop variable. It should be Score[Index] ← 0. The closing square bracket is missing. The statement inside the loop should be OUTPUT Mark[Index].
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 449–458) and word search (Modules 439–458).
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
FOR Index ← 1 TO 30Fill in the Blanks
Spot the Error
Student with a class code? Join your class →