Knowledge Organiser: Iteration
Part of Iteration (Loops) · GCSE GCSE Computer Science revision
This topic summary covers Knowledge Organiser: Iteration within Iteration (Loops) for GCSE Computer Science. Revise Iteration (Loops) in Programming for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This is a high-frequency topic, so it is worth revising until the explanation feels precise and repeatable. It is section 8 of 8 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Topic position
Section 8 of 8
Practice
15 questions
Recall
8 flashcards
Knowledge Organiser: Iteration
Key Terms
- Iteration: Repeating a block of code — also called a loop
- FOR loop: A count-controlled loop that repeats a fixed number of times
- WHILE loop: A condition-controlled loop that repeats while a condition is true (may run 0 times)
- DO-WHILE loop: A loop that always runs at least once, then checks the condition
- Infinite loop: A loop whose condition never becomes false — a common bug
- Off-by-one error: A bug caused by using the wrong loop boundary (e.g. 1 to 10 vs 0 to 9)
Must-Know Facts
- FOR loops are used when the number of iterations is known in advance
- WHILE loops are used when the number of iterations is unknown
- A WHILE loop may execute zero times if the condition is false at the start
- DO-WHILE always executes the body at least once before checking the condition
- WHILE loop conditions must eventually become false to avoid an infinite loop
Key Concepts
- FOR loop:
for i = 1 to 5 ... next i - WHILE loop:
while condition ... endwhile - DO-WHILE:
do ... until condition - Input validation pattern:
do ... age = input(...) ... until age >= 0 AND age <= 120 - Sum 1 to 100:
total = 0 ... for i = 1 to 100 ... total = total + i ... next i
Common Mistakes
- Using a FOR loop when the number of repetitions is unknown: FOR loops are for a fixed number of iterations — use WHILE or DO-WHILE when repeating until a condition is met (e.g. user input validation)
- Confusing WHILE and DO-WHILE: A WHILE loop may run zero times if the condition is false from the start; a DO-WHILE always runs at least once — this matters when validating user input
- Creating infinite loops by never updating the condition variable: If the variable controlling a WHILE loop never changes inside the loop, the condition never becomes false
- Off-by-one errors in FOR loops:
for i = 1 to 5runs 5 times (1,2,3,4,5);for i = 0 to 4also runs 5 times — confusing the two is a very common bug - Not indenting loop bodies in pseudocode: Indentation is required to show which statements are inside the loop — examiners expect it in written pseudocode answers
Revise this topic interactively on PrepWise — self-test mode, tap-to-reveal definitions, and Common Mistakes from examiners.
Try the interactive Knowledge Organiser — free →