StudyBrixFree worksheets, study guides and courses

Computer science · Grades 8–12

Nested loops

This product applies when the inner count is constant for each outer iteration.

Make a worksheet

The key idea

This product applies when the inner count is constant for each outer iteration.

total executions = outer iterations × inner iterations

Worked examples

An outer loop runs 22 times. Each time, an inner loop prints once on each of 14 iterations. How many prints occur?

22 × 14 = 308

308

An outer loop runs 17 times. Each time, an inner loop prints once on each of 14 iterations. How many prints occur?

17 × 14 = 238

238

Try it yourself

  1. An outer loop runs 5 times. Each time, an inner loop prints once on each of 20 iterations. How many prints occur?

  2. An outer loop runs 18 times. Each time, an inner loop prints once on each of 20 iterations. How many prints occur?

Check your understanding

Answers and marking notes
  1. 100

    5 × 20 = 100

  2. 360

    18 × 20 = 360

Learning preview · teacher review required. Grade bands are approximate, not official curriculum alignment.