FOR…TO…NEXT count-controlled loop
A count-controlled loop that repeats the indented lines end - start + 1 times, adding 1 to the counter each time. It is closed by NEXT Count, which names the same counter.
Understanding FOR…TO…NEXT count-controlled loop in IGCSE Computer Science Paper 2
What it does: 1 TO 5 gives 5 - 1 + 1 = 5 repeats. The indented OUTPUT is the loop body and NEXT Count closes the loop. 7 - 3 + 1 = 5, so Num takes the values 3, 4, 5, 6, 7. The counter goes up by 1 each time and NEXT Num names the same counter. The loop runs end - start + 1 times, so 10 - 1 + 1 = 10. 7 - 3 + 1 = 5. Num takes the values 3, 4, 5, 6 and 7. Without STEP, the counter increases by 1 on every repeat.
Common mistakes: NEXT must name the same counter that FOR started with. It should be NEXT Count, not NEXT Total. A FOR loop gives the counter its start value with the assignment arrow <-, not =. It should be FOR Num <- 1 TO 3.
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 369–378) and word search (Modules 358–378).
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 →