Caffeinated Coder
Book an appointment
Lesson 04 · Basics

Control flow: if, else and while

A program runs its lines one after another, top to bottom, until a control-flow statement changes the order. Follow a twelve-line countdown as an arrow marks the line that runs: a while loop repeats its body while n > 0 is true, an if/else picks one of two lines to print on each pass, and the loop stops when its condition turns false.

10 min9 steps5 questionsBeginner
Fig 4 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.