A WHILE loop ended by a rogue value
Loop that repeats until the user types a rogue (sentinel) value such as -1. INPUT before the loop and again at the end of the body; the rogue value is not counted or totalled.
Understanding A WHILE loop ended by a rogue value in IGCSE Computer Science Paper 2
What it does: The INPUT at the end of the body fetches the next value, which the WHILE condition then checks. Without it the loop would never end. A rogue value is a special value that is not real data. It tells the loop to stop.
Common mistakes: The total must start at 0. Starting at 1 adds an extra 1 to the answer. It should be Total <- 0. The first INPUT before the loop reads into the wrong variable. Mrk is not Mark, so the loop test uses a value that was never read. It should be INPUT Mark.
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 379–388) and word search (Modules 379–398).
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
WHILE Number <> -1 DOFill in the Blanks
Spot the Error
Student with a class code? Join your class →