FOR ... TO ... NEXT
Repeats the statements below once for each whole number from 1 to 30 inclusive. Index is an INTEGER that changes automatically each time. Close the loop with NEXT Index.
Understanding FOR ... TO ... NEXT in IGCSE Computer Science Paper 2
What it does: Count goes 1, 2, 3, 4, 5 without any Count ← Count + 1 line, because the FOR loop changes it automatically. The FOR loop counts in whole numbers, so the variable holding the count is declared with the INTEGER data type. The loop runs once for each integer from 1 to 30 inclusive, so it repeats 30 times. A FOR loop in Cambridge pseudocode ends with NEXT followed by the same identifier. There is no ENDFOR. The FOR loop increases the loop variable by itself on every repeat, so you do not add 1 yourself. Assignment uses the arrow ←. The = sign is used for comparison, not for giving the loop variable its start value.
Common mistakes: A FOR loop gives its loop variable a starting value with the assignment arrow ←, not =. It should be FOR Index ← 1 TO 30. NEXT must repeat the same identifier that follows FOR. The loop variable is Count, so the line 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 166–175) and word search (Modules 166–187).
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 →