FOR ... TO ... NEXT loop (7a)
Repeats the code once for each integer from 1 to 30 inclusive, up to NEXT Index. Runs once if both values are equal and not at all if the start value is bigger.
Understanding FOR ... TO ... NEXT loop (7a) in IGCSE Computer Science Paper 2
What it does: NEXT Index marks the end of the loop body and uses the same identifier that was named in the FOR line. 10 is greater than 1, so there are no integers to count up through and the statements inside the loop are skipped. A FOR loop includes both the start value and the end value, so Count takes the values 1, 2, 3, 4 and 5. Cambridge pseudocode closes a FOR loop with NEXT followed by the loop variable. ENDFOR is not used. When value1 equals value2 there is exactly one integer in the range, so the loop body runs one time.
Common mistakes: A FOR loop in Cambridge pseudocode ends with NEXT followed by the loop variable, not ENDFOR. It should be NEXT Index. A FOR loop uses the keyword TO between the start and end values. UNTIL belongs to REPEAT loops. It should be FOR Index ← 1 TO 10.
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 37–46) and word search (Modules 27–46).
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 →