22 min read
Selection Flowcharts
Use a decision diamond to choose between two paths — with one-way and two-way examples.
Selection: Making a Choice
Selection lets an algorithm take different paths depending on a condition. The condition goes in a decision diamond and must have a yes/no answer, usually a comparison:
| Symbol | Meaning |
|---|---|
| > | greater than |
| < | less than |
| >= | greater than or equal to |
| <= | less than or equal to |
| = (or ==) | equal to |
| ≠ (or !=) | not equal to |
One-Way Selection: Do Something Only If…
Example 1 — the shop discount
Read this flowchart as text
- Terminator: Start (then → INPUT total)
- Input/output: INPUT total (then → total > 5000?)
- Decision: total > 5000? (Yes → total = total × 0.9; No → OUTPUT total)
- Process: total = total × 0.9 (then → OUTPUT total)
- Input/output: OUTPUT total (then → Stop)
- Terminator: Stop
Two-Way Selection: Either This or That
Example 2 — pass or fail
Read this flowchart as text
- Terminator: Start (then → INPUT mark)
- Input/output: INPUT mark (then → mark >= 40?)
- Decision: mark >= 40? (Yes → OUTPUT "Pass"; No → OUTPUT "Fail")
- Input/output: OUTPUT "Fail" (then → Stop)
- Input/output: OUTPUT "Pass" (then → Stop)
- Terminator: Stop
Designing a Selection
- Write the condition as a question with a yes/no answer: "mark >= 40?"
- Decide what happens on Yes and on No.
- Label both exits.
- Bring the paths back together (to the next step, or to Stop).
Practice
A shop gives free delivery on orders of 3,000 or more. Which decision is correct?
More lessons in Algorithms, Flowcharts and Pseudocode · Next: Nested Decisions · Previous: Sequence Flowcharts
