Selection inside a loop (7c)
An IF placed inside a loop body is tested again on every pass, so each pass can take a different branch. It is often used to count items that meet a condition.
Understanding Selection inside a loop (7c) in IGCSE Computer Science Paper 2
What it does: The IF is tested for every element in the array. Passes increases only when the mark meets the condition, so it counts the items that qualify. Rain[Day] has a different value on each pass, so the IF can choose THEN on one pass and ELSE on another. Each pass can therefore output a different message. The ENDIF must close the IF inside the loop body, before NEXT. The IF is fully inside the loop. Count ← Count + 1 adds to the running total. Count ← 1 just resets the value to 1 each time, so it never counts more than one.
Common mistakes: A FOR loop sets its counter with the assignment arrow ←, not =. The line should be FOR Count ← 1 TO 5. Count is set back to 1 each time the IF is true, so it never builds up. To count items it must add 1 each time: Count ← Count + 1.
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 176–187) 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
IF inside a loopFill in the Blanks
Spot the Error
Student with a class code? Join your class →