FOR…TO…NEXT loop (7d)
Repeats the lines up to NEXT Count a fixed number of times. Count starts at 1, goes up automatically, and both the start and end values are included. STEP changes the jump.
Understanding FOR…TO…NEXT loop (7d) in IGCSE Computer Science Paper 2
What it does: STEP changes the size of the jump. Starting at 2 and adding 2 each time gives 2, 4, 6, 8, 10. The loop variable Count changes automatically, so OUTPUT Count shows 1, then 2, then 3, and NEXT Count ends the loop. Both the start value (1) and the end value (5) are included, so Count takes the values 1, 2, 3, 4, 5. Cambridge FOR loops use the ← assignment arrow and TO. They do not use DO (that belongs to WHILE) or = for assignment. With a negative STEP the loop counts down. It starts at 10 and goes 10, 9, 8 ... down to 1.
Common mistakes: The start value of a FOR loop is given with the assignment arrow, not an equals sign. It should be FOR Count ← 1 TO 5. NEXT must name the same loop variable that the FOR line uses. The loop variable is Count, so it should be NEXT Count.
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 265–274) and word search (Modules 254–274).
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 Count ← 1 TO 10Fill in the Blanks
Spot the Error
Student with a class code? Join your class →