Mathematics I / Loops and Iteration
Practice question · True or false

A while loop can express any for loop, but some while loops cannot be written as a for loop.

Hints
  1. What does a for loop bundle together?
  2. Initialise, test, update, all available either way.
Show the answer

False

Why

False. Both directions hold: a for is a while with the initialiser, test and update written in one place, and any while can be written as a for with those slots filled or left empty. The choice is about readability, for when the iteration count is known up front, while when the stopping condition is discovered as you go.

Read the lesson: Loops and Iteration →

Practise Loops and Iteration

The app has 6 more questions on this lesson, and keeps your place in the course. Mathematics I is free to start.

More questions on Loops and Iteration