Control Flow
By default code runs top to bottom, one statement after another. Control flow is what lets a
program choose and repeat instead. Branches (if / else) run one block or another
depending on a true/false condition; loops (while, for) run a
block over and over until a condition changes.
if temperature > 30
print "hot"
else
print "fine"
while fuel > 0
drive() repeat until fuel runs out
Every condition ultimately reduces to a boolean, so control flow rests directly on
logic — and, or, and not combine conditions exactly as
they do in a truth table. Branches and loops are enough, in principle, to express any computation.
Related concepts
Related docs
hierarchy prerequisite related
Sources