Iteration

Computer Science: KS3, topic 2.3.7

Iteration

Iteration allows a group of statements to be repeated multiple times. Iteration statements are often called loops.

Indefinite iteration

Indefinite iteration

  • A block of code will repeat whilst a specified condition is true.
  • For example: the while loop will continue to execute an indented code block while a certain condition is true.
Definite iteration

Definite iteration

  • A block of code will repeat a known number of times.
  • For example: a for loop will execute an indented block for each value in a list of values.
Flow diagram

Flow diagram

  • A flow diagram for iteration uses the diamond shape.

Test yourself on Iteration

  • What are the two types of iteration?

  • What is definite iteration?

Practise this topic for free