CodingNic

Control Flow

Module Overview

Control Flow 5 min read

Module Overview

Control Flow

Code has run top to bottom so far, one line after another. Real programs need to make decisions and repeat work. This module covers conditionals, which choose what runs, and loops, which repeat it.

Why This Matters

Almost everything a program does comes down to control flow: showing a message only if something is true, processing every item in a list, retrying until something succeeds. Without it, a program can only ever do one fixed sequence of steps.

What You’ll Learn

  • Branching with if, else if, and else
  • Choosing between several fixed options with switch
  • Repeating code with for, while, and do...while loops
  • Controlling a loop mid-run with break and continue
  • Nesting loops inside one another

Outcome

By the end of this module, you’ll be able to write code that makes decisions and repeats work automatically, instead of running the same fixed sequence every time.

Let’s get started.