Skip to content
BENIBIX Learn

Control Flow

Development🧩 Programming ConceptsControl Flow

Also known as Flow of Control

The order a program runs its steps in. Ifs skip lines; loops repeat them.

Think of it like

Think of it like a board game. Most turns you move ahead, but some squares send you back or let you skip.

Example

A quiz app asks a question, then jumps to the right or wrong screen. Then it loops back for the next question.

Why it matters

Without control flow, a program could only run every line once, in order. Choices and repeats come from here.

Definition

Control flow is the order in which a program runs its steps. By default it goes from top to bottom, one line at a time. Ifs let it skip some lines, and loops make it repeat others. Calling a function makes it jump to that function and then come back. Reading code well means following this path, not just reading lines.

Common mistake

Reading code top to bottom like a book. The real order follows the ifs, loops and calls.

Key takeaways

  1. 1
    Top to bottom first. Lines run in order unless told otherwise.
  2. 2
    Choose and repeat. Ifs pick a path; loops go round again.
  3. 3
    Jump and return. A function call goes away and comes back.

Learn it properly