Flowcharts
IB Syllabus: B1.1.4 – Trace flowcharts for a range of programming algorithms using standard symbols.
Table of Contents
- Why This Page Exists
- Standard Flowchart Symbols
- Reading a Flowchart
- Drawing Flowcharts: Rules
- Flowchart Tracing Practice
- Quick Check
- Trace Exercise
- Code Completion
- Practice Exercises
- Connections
Why This Page Exists
A flowchart is a visual representation of an algorithm. It shows the sequence of steps, decisions, and loops using standard symbols. Flowcharts make algorithms easier to understand, trace, and communicate – especially before you start coding.
IB exams frequently ask you to trace a flowchart (follow it step by step and determine the output) or draw a flowchart for a given algorithm.
Standard Flowchart Symbols
The IB uses six standard symbols. You must know all of them.
| Symbol | Shape | Purpose | Example |
|---|---|---|---|
| Start/End | Rounded rectangle (oval) | Marks the beginning or end of the algorithm | Start, End |
| Process | Rectangle | An action, calculation, or assignment | total = total + price |
| Decision | Diamond | A yes/no question that creates a branch | Is age >= 18? |
| Input/Output | Parallelogram | Reading input or displaying output | Read name, Print total |
| Flowline | Arrow | Shows the direction of flow between symbols | (arrows connecting shapes) |
| Connector | Small circle | Connects parts of a flowchart (used when the chart spans multiple sections) | (circle with a label) |
Decision diamonds always have exactly two exits: Yes and No (or True and False). Always label both branches.
Reading a Flowchart
Example 1: Simple Decision
This flowchart determines whether a person can vote.
┌───────┐
│ Start │
└───┬───┘
│
┌───▼────────┐
│ Read age │
└───┬────────┘
│
◇───▼───◇
╱ age >= 18? ╲
╱ ╲
Yes No
│ │
▼ ▼
┌────────────┐ ┌──────────────┐
│ Print │ │ Print │
│ "Can vote" │ │ "Cannot vote"│
└─────┬──────┘ └──────┬───────┘
│ │
└───────┬────────┘
│
┌───▼───┐
│ End │
└───────┘
Tracing: If age = 20, follow the Yes branch. Output: “Can vote”. If age = 15, follow the No branch. Output: “Cannot vote”.
Example 2: Loop (Counting)
This flowchart prints numbers 1 to 5.
┌───────┐
│ Start │
└───┬───┘
│
┌───▼──────┐
│ count = 1│
└───┬──────┘
│
◇───▼────◇
╱ count <= 5? ╲
╱ ╲
Yes No ──────► ┌─────┐
│ │ End │
▼ └─────┘
┌──────────────┐
│ Print count │
└──────┬───────┘
│
┌──────▼───────────┐
│ count = count + 1│
└──────┬───────────┘
│
└───────── (back to decision)
Trace:
| Step | count | count <= 5? | Output |
|---|---|---|---|
| 1 | 1 | Yes | 1 |
| 2 | 2 | Yes | 2 |
| 3 | 3 | Yes | 3 |
| 4 | 4 | Yes | 4 |
| 5 | 5 | Yes | 5 |
| 6 | 6 | No | (exit) |
Output: 1, 2, 3, 4, 5
Example 3: Sum with Sentinel Value
This flowchart reads numbers until the user enters -1, then prints the total.
┌───────┐
│ Start │
└───┬───┘
│
┌───▼──────┐
│ total = 0│
└───┬──────┘
│
┌───▼──────────┐
│ Read number │
└───┬──────────┘
│
◇───▼────────◇
╱ number != -1? ╲
╱ ╲
Yes No ──► ┌──────────────┐
│ │ Print total │
▼ └──────┬───────┘
┌────────────────────┐ │
│ total = total + │ ┌───▼───┐
│ number │ │ End │
└────────┬───────────┘ └───────┘
│
┌────▼─────────┐
│ Read number │
└────┬─────────┘
│
└──── (back to decision)
Trace with inputs 10, 20, 5, -1:
| Step | number | number != -1? | total |
|---|---|---|---|
| Init | – | – | 0 |
| Read | 10 | Yes | 10 |
| Read | 20 | Yes | 30 |
| Read | 5 | Yes | 35 |
| Read | -1 | No | – |
| Output | – | – | Print 35 |
Drawing Flowcharts: Rules
- One Start, one End – every flowchart begins with Start and ends with End
- Flowlines show direction – use arrows, always flowing top-to-bottom or left-to-right where possible
- Decision diamonds have two exits – label them Yes/No or True/False
- Every path must reach End – no dead ends or orphaned branches
- Keep it clean – avoid crossing flowlines; use connectors if needed
Common exam mistake: Forgetting to label the True/False branches on a decision diamond. Always label both exits.
Flowchart Tracing Practice
To trace a flowchart:
- Start at the Start symbol
- Follow the flowlines, executing each process and I/O step
- At each decision, evaluate the condition and follow the correct branch
- Record variable values and outputs at each step
- Continue until you reach End
Use a trace table to track variable values and outputs systematically.
Quick Check
Q1. Which flowchart symbol represents a decision?
Q2. What does a parallelogram represent in a flowchart?
Q3. How many exits does a decision diamond have?
Q4. In the counting flowchart (Example 2), what is the last number printed?
Q5. What tool should you use to trace a flowchart systematically?
Trace Exercise
Trace this algorithm and determine the output.
Trace: The flowchart reads numbers and counts how many are positive. Inputs: 5, -3, 8, 0, -1 (sentinel).
START
total = 0, positives = 0
READ number
WHILE number != -1:
total = total + number
IF number > 0 THEN positives = positives + 1
READ number
PRINT total, positives
END| number | number != -1? | total | number > 0? | positives |
|---|---|---|---|---|
| 5 | Yes | Yes | ||
| -3 | Yes | No | ||
| 8 | Yes | Yes | ||
| 0 | Yes | No | ||
| -1 | No | Output: total = , positives = | ||
Code Completion
Match each flowchart symbol to its purpose.
Fill in the blanks: Name the flowchart symbol for each purpose.
// A yes/no question that creates two branches
// Symbol:
// Reading user input or displaying output
// Symbol:
// A calculation or assignment (e.g., total = total + 1)
// Symbol:
// Marks the beginning or end of the algorithm
// Symbol: Practice Exercises
Core
-
Trace a flowchart – Trace the counting flowchart (Example 2) but change the condition to
count <= 3. What is the output? -
Draw a flowchart – Draw a flowchart that reads a student’s grade (0-100) and prints “Pass” if the grade is 50 or above, or “Fail” if below 50. Use correct symbols.
-
Symbol identification – For each of the following actions, state which flowchart symbol you would use:
- (a) Check if temperature is above 30
- (b) Calculate total = price * quantity
- (c) Display “Thank you”
- (d) Begin the algorithm
Extension
-
Loop flowchart – Draw a flowchart that reads numbers until the user enters 0, then prints the average of all numbers entered (not counting the 0). Include the trace table for inputs 10, 20, 30, 0.
-
Nested decision – Draw a flowchart for a grading system: 90+ = “A”, 80-89 = “B”, 70-79 = “C”, 60-69 = “D”, below 60 = “F”. Use nested decision diamonds.
Challenge
- Algorithm to flowchart – Convert the following algorithm to a flowchart, then trace it with the input array [4, 1, 7, 2]:
max = arr[0] i = 1 WHILE i < length: IF arr[i] > max THEN max = arr[i] i = i + 1 PRINT max
Connections
- Prerequisites: CT Concepts – flowcharts visualise the algorithms designed through CT
- Prerequisites: Problem Specification – the problem must be understood before drawing a solution
- Forward: Selection – decision diamonds become if/else in code
- Forward: Iteration – loop flowcharts become for/while in code
- Related: Algorithms – searching and sorting can be represented as flowcharts