Skip to content

Nested loops and patterns

Handout

A loop inside a loop

  • You can put one loop inside another. The inner loop runs fully for each step of the outer loop.
  • This is how you work with rows and columns, or compare every pair of items.
  • If the outer loop runs R times and the inner runs C times, the inner body runs R × C times.

A 3-by-4 grid of stars: the outer loop walks the rows, the inner loop walks the columns

Handout

Log in or create account

IGCSE & A-Level