Skip to content
AI-grafen
CBuilderProgramming· about 30 min· fundamentals that rarely change· verified 2026-09-20· EN

Programming logic — variables, conditions, loops

Be able to follow and predict what a short program does: how variables change, when a condition is true, and how many times a loop runs.

Prerequisites

Intuition

Three concepts carry all of programming:

  • Variable — a named box that can hold a value: score = 0.
  • Condition — a question that is true or false: score > 10.
  • Loop — do something several times: repeat 5 times.

To trace a program means to walk through it line by line, writing down what every variable contains. It is the single most important skill for finding faults.

Code

total = 0
for i from 1 to 4:
    if i is even:
        total = total + i

The trace:

ieven?total
1no0
2yes2
3no2
4yes6

Answer: 6. Draw the table every time you are unsure — the brain loves to skip steps.

Mastery means

  • Traces a variable's value through a loop
  • Works out which values make a condition true

Sign in to do the exercises and build your mastery up.

Sources

All the sources and licences