Lompat ke konten

Nested loops and patterns

English

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 inner loop runs 4 times for each of 3 outer passes, 12 times in all

Lembar Kerja

Masuk atau buat akun

IGCSE, A-Level & AP