Introduction to Programming (logic, algorithms, simple code)
What this domain tests
This domain tests algorithmic thinking: breaking a problem into steps, expressing it as pseudocode or a flowchart, and tracing simple sequence, selection and repetition.
Core rules
- An algorithm is a finite, ordered, unambiguous set of steps that solves a problem.
- Flowchart symbols: oval = start/end; parallelogram = input/output; rectangle = process; diamond = decision; arrows = flow.
- Three control structures: sequence (one step after another), selection (if/else), iteration (loop).
- A variable is a named store; assignment puts a value into it. Use == for comparison and = for assignment in many languages.
- Trace a program by making a table of variable values after each step.
- Check boundary cases: zero, negative numbers, equal values and the first/last item.
Worked example
Find the largest of three numbers a, b, c. Pseudocode: input a, b, c max ← a if b > max then max ← b if c > max then max ← c print max Trace with a=7, b=3, c=9: max starts at 7; 3 > 7 is false; 9 > 7 is true, so max becomes 9; output 9. The reasoning is to keep a current best value and replace it only when a larger one appears.
Traps
- Forgetting to initialise max can produce garbage or an error.
- Using < instead of > reverses the logic.
- A decision diamond has one input and two labelled outputs, not three.
- Loop conditions that never become false cause infinite loops.
- Printing inside a loop may produce many outputs instead of one final answer.