MODULE 2 • LESSON 05
An algorithm is an idea: a sequence of steps that solves a problem. Before that idea can be checked, discussed or turned into a program, it has to be written down. The CAPE syllabus names three ways of doing this: narrative (ordinary sentences), flowcharts (symbols joined by arrows) and pseudocode (structured, program-like English). Each has strengths and weaknesses, and in exams you will be asked to read, write and convert between all three.
In this lesson you will learn the rules for each representation, explore the standard flowchart symbols, and step through one algorithm shown three ways at once, with the current sentence, pseudocode line and flowchart symbol all lit up together. Then you will see the same algorithms written in C.
What you will learn
- What narrative, flowcharts and pseudocode are, and how to write each one well.
- The standard flowchart symbols and the rules for drawing a correct flowchart.
- Common pseudocode keywords and conventions for input, output, assignment, selection and loops.
- The advantages and disadvantages of each representation, and when to use which.
- How to convert an algorithm from one representation to another.
- How each representation maps onto a C program.
Part 1: One algorithm, three ways
Here is a small algorithm written all three ways. It decides whether a student can enter a competition (age 13 to 18 inclusive).
Narrative: Ask for the student’s age. If the age is between 13 and 18, including both, display “Eligible”; otherwise display “Not eligible”.
Pseudocode:
INPUT age IF age >= 13 AND age <= 18 THEN OUTPUT "Eligible" ELSE OUTPUT "Not eligible" ENDIF
Flowchart:
All three describe exactly the same steps. What changes is who they suit and how precisely they say it. The table below compares them; the rest of the lesson looks at each in turn.
| Narrative | Flowchart | Pseudocode | |
| Form | Sentences in everyday language | Standard symbols joined by flow lines | Structured English with keywords and indentation |
| Best for | Explaining the idea to anyone, including non-programmers | Seeing the flow of control, especially decisions and loops | Planning code; it converts almost line by line into a program |
| Main weakness | Can be vague, ambiguous or long-winded | Large and slow to draw or change for long algorithms | Not standardised; needs some programming knowledge to read |
Part 2: Narrative
A narrative describes the algorithm in ordinary language, usually as a paragraph or a numbered list of sentences. It is the most natural way to start, and it is how a client or teacher will usually describe a problem to you.
Writing a good narrative. Because everyday language is easily misunderstood, apply the properties from the previous lesson as you write:
- Number the steps, one action per step.
- Name the values (“the total”, “the count of passes”) and use the same name every time.
- State conditions precisely (“50 or more”, not “a good mark”).
- Say clearly what repeats and when the repetition stops (“for each of the 4 students”, “until -1 is entered”).
Worked example. A weak narrative: “Get the marks and work out how many people passed.” A better narrative: “1. Set the pass count to 0. 2. For each of the 4 students, read the mark; if it is 50 or more, add 1 to the pass count. 3. Display the pass count.” The second version can be followed exactly and converted into pseudocode with almost no guesswork.
| Advantages of narrative | Disadvantages |
| Anyone can read it; no special symbols or keywords. | Ordinary language is often ambiguous. |
| Quick to write for a first idea. | Long algorithms become hard to follow. |
| Good for agreeing on the idea with a client. | Decisions and loops are hard to see. |
| Further from program code, so conversion needs more thought. |
Part 3: Flowcharts
A flowchart shows an algorithm as a diagram: each step is drawn as a standard symbol, and flow lines (arrows) show the order in which the steps are carried out. Because the flow of control is drawn rather than described, flowcharts are very good at showing decisions and loops.
The symbols
| Symbol | Shape | Used for | Example |
| Terminal | Rounded rectangle (oval) | Start and Stop | Start |
| Input / Output | Parallelogram | Reading data in or showing results | Input mark; Output total |
| Process | Rectangle | Calculations and assignments | total = total + mark |
| Decision | Diamond | A Yes/No question (selection or loop test) | mark ≥ 50 ? |
| Flow line | Arrow | Shows which step comes next | ↓ |
| Connector | Small circle with a label | Joins parts of a chart that are far apart or on another page | (A) |
| Predefined process | Rectangle with double sides | A module (subroutine) defined elsewhere | CalcFee |
Try it 1Flowchart symbol explorer
Explore: tap a symbol name to see its shape, its meaning and the matching pseudocode. Match: then work through the ten steps below and pick the symbol each one needs.
Match the symbol
Rules for a correct flowchart
- Exactly one Start; every path must end at a Stop.
- Flow normally runs top to bottom (and left to right). Use arrowheads, especially on lines that go back up for a loop.
- A process or input/output symbol has one line in and one line out.
- A decision has one line in and exactly two lines out, labelled Yes/No (or True/False). Write the condition as a question.
- Flow lines should not cross. If they must, or the chart runs onto another page, use connectors.
- Keep the text in each symbol short: one action per symbol.
Worked example: a flowchart with nested decisions
A courier charges by parcel weight w (kg): up to 2 kg costs $25; over 2 kg and up to 10 kg costs $25 plus $6 for each kg over 2; over 10 kg costs $73 plus $4 for each kg over 10. A second decision is placed on the No path of the first, so it is only asked when the first answer is No. This is called a nested decision.
Check it with a test value. For w = 12: is 12 ≤ 2? No. Is 12 ≤ 10? No. So cost = 73 + (12 − 10) × 4 = 81. Following a value through every decision like this is the quickest way to find a wrong branch.
| Advantages of flowcharts | Disadvantages |
| The flow of control is easy to see; loops and branches stand out. | Take time to draw, and are awkward to change. |
| Standard symbols are understood widely. | Long algorithms need many pages and connectors. |
| Good for tracing and for finding logic errors. | Complex nested decisions become cluttered. |
| Useful documentation for maintaining a program. | Do not map as directly onto code as pseudocode. |
Part 4: Pseudocode
Pseudocode describes an algorithm in a structured, program-like form using a small set of keywords, but without the strict grammar of a real language. It is not executed by a computer, so there is no single official version. What matters is that it is clear and consistent.
Common conventions
| Purpose | Pseudocode | Example |
| Input | INPUT or READ | INPUT mark |
| Output | OUTPUT, PRINT or DISPLAY | OUTPUT "Total: ", total |
| Assignment | ← (or =) | total ← total + mark |
| Selection | IF … THEN … ELSE … ENDIF | IF mark >= 50 THEN OUTPUT "Pass" ENDIF |
| Bounded loop | FOR … TO … ENDFOR | FOR i ← 1 TO 10 |
| Pre-test loop | WHILE … DO … ENDWHILE | WHILE mark <> -1 DO |
| Post-test loop | REPEAT … UNTIL | REPEAT … UNTIL answer = "N" |
| Comparison | =, <>, <, <=, >, >= | age >= 18 |
| Logic | AND, OR, NOT | age >= 13 AND age <= 18 |
Good habits:
- Write keywords in CAPITALS so they stand out from variable names.
- Indent the steps inside an IF or a loop, and close every structure (ENDIF, ENDWHILE, ENDFOR).
- Use meaningful variable names and the same assignment symbol throughout.
- One step per line. Do not slip into real C syntax (semicolons, braces) unless the question asks for code.
Worked example: the courier charges in pseudocode. Notice how the nested decision in the flowchart becomes an IF inside the ELSE part of another IF.
INPUT w
IF w <= 2 THEN
cost ← 25
ELSE
IF w <= 10 THEN
cost ← 25 + (w - 2) * 6
ELSE
cost ← 73 + (w - 10) * 4
ENDIF
ENDIF
OUTPUT cost
| Advantages of pseudocode | Disadvantages |
| Close to program code, so it converts easily into any language. | No single standard; notation differs between books and teachers. |
| Quick to write and easy to change. | Harder for non-programmers to read. |
| Precise: keywords and indentation reduce ambiguity. | The flow of control is less visual than in a flowchart. |
| Independent of any one language. | Cannot be run, so errors are found only by tracing. |
Part 5: Watch all three at once
The next activity shows one algorithm, "count how many of 4 students passed (50 or more)", as a narrative, as pseudocode and as a flowchart. Each tap of Next carries out one step. The part of each representation that matches the step lights up in orange, so you can see that they really are the same algorithm.
Try it 2Three views, one algorithm
Tap Next to carry out one step. Watch the orange highlight move through the narrative, the pseudocode and the flowchart together. Other marks swaps in a second set of marks that includes some boundary values.
Narrative
Pseudocode
Flowchart
Look at what happens with a mark of exactly 50: the test is mark ≥ 50, so 50 counts as a pass. If the pseudocode had said mark > 50, the narrative ("50 or more") and the program would disagree. Checking that all three representations say the same thing at the boundaries is a good habit.
Part 6: Converting between representations
Exams often give you an algorithm in one form and ask for it in another. The mapping is mechanical once you know it:
| Flowchart | Pseudocode | Narrative |
| Start / Stop terminal | (beginning and end of the algorithm) | "Begin by…", "Finally…" |
| Parallelogram | INPUT / OUTPUT | "Ask for…", "Display…" |
| Rectangle | variable ← expression | "Add… to…", "Set… to…" |
| Diamond whose two paths join further down | IF … THEN … ELSE … ENDIF | "If…, otherwise…" |
| Diamond with a line looping back up to it | WHILE … DO … ENDWHILE (or REPEAT … UNTIL if the test is at the bottom) | "Repeat… while… / until…" |
| Predefined process box | CALL ModuleName | "Carry out the… procedure" |
Flowchart to pseudocode
- Start at the Start terminal and follow the arrows.
- Write one line for each parallelogram or rectangle.
- At a diamond, decide: do both paths continue down and join? That is an IF. Does one path go back up to before the diamond? That is a loop. If the diamond is at the top of the loop, use WHILE; if it is at the bottom, use REPEAT … UNTIL (careful: UNTIL uses the opposite condition to WHILE).
- Indent the steps inside each IF or loop, and close each structure.
Pseudocode to flowchart
- Draw Start, then one symbol per line, choosing the shape by the keyword (INPUT/OUTPUT → parallelogram; ← → rectangle; IF/WHILE → diamond).
- For an IF, draw the diamond with Yes and No paths, and bring them back together after ENDIF.
- For a WHILE, draw the diamond, the body below the Yes exit, and a line from the end of the body back up to the diamond. The No exit leaves the loop.
- Finish with Stop, then check every diamond has two labelled exits and every path reaches Stop.
Worked example. Convert this pseudocode into a narrative: total ← 0; INPUT n; WHILE n <> 0 DO total ← total + n; INPUT n ENDWHILE; OUTPUT total. Answer: "Set the total to 0. Read a number. While the number is not 0, add it to the total and read the next number. When 0 is entered, display the total." Every keyword has become a phrase, and the sentinel (0) is stated clearly.
Part 7: From the representations to C
The pass counter from Part 5 in C. Put the pseudocode beside it: WHILE … ENDWHILE becomes while ( ) { }, IF … ENDIF becomes if ( ) { }, INPUT becomes scanf and OUTPUT becomes printf.
#include <stdio.h>
int main(void)
{
int passes = 0;
int i = 1;
int mark;
while (i <= 4) {
printf("Mark %d: ", i);
scanf("%d", &mark);
if (mark >= 50) {
passes = passes + 1;
}
i = i + 1;
}
printf("\nPasses: %d\n", passes);
return 0;
}
Sample input: 72 45 50 38
Output:
Mark 1: Mark 2: Mark 3: Mark 4: Passes: 2
The courier charges in C. The nested IF in the pseudocode becomes an if … else if … else chain, and the weight uses float because parcels can weigh 2.5 kg.
#include <stdio.h>
int main(void)
{
float w, cost;
printf("Parcel weight in kg: ");
scanf("%f", &w);
if (w <= 2) {
cost = 25;
} else if (w <= 10) {
cost = 25 + (w - 2) * 6;
} else {
cost = 73 + (w - 10) * 4;
}
printf("\nCost: $%.2f\n", cost);
return 0;
}
Sample input: 12
Output:
Parcel weight in kg: Cost: $81.00
Notice that the C programs needed details that the pseudocode left out: variable types (int, float), the format of input and output, and prompts for the user. That is the job of pseudocode: capture the logic, and leave the language details for later.
Which representation should you use?
- Talking to a client or describing a problem: narrative.
- Checking or explaining the logic of decisions and loops, or tracing for errors: flowchart.
- Planning a program you are about to write: pseudocode.
- In an exam: whichever the question names. If it says "using pseudocode", a flowchart earns nothing, and vice versa.
Try it 3Symbols and representations practice
Pick a mode. "Which symbol?" gives a step to draw. "Which representation?" describes a feature to match. Tap New question for another.
Summary
| Representation | Remember |
| Narrative | Numbered sentences; anyone can read it; precise wording needed to avoid ambiguity. |
| Flowchart | Terminal, parallelogram, rectangle, diamond, arrows, connector, predefined process. One Start; every path reaches Stop; decisions have two labelled exits. |
| Pseudocode | Keywords (INPUT, OUTPUT, ←, IF/ENDIF, WHILE/ENDWHILE, FOR/ENDFOR, REPEAT/UNTIL), indentation, consistency. |
| Converting | Diamond that rejoins = IF; diamond with a back-arrow = loop; one symbol per line. |
Review questions
1. Name the THREE ways of representing an algorithm listed in the syllabus.
Show answer
Narrative, flowcharts and pseudocode.
2. Draw (or describe) the flowchart symbols for: (a) a decision, (b) input/output, (c) a process, (d) start/stop.
Show answer
(a) Diamond. (b) Parallelogram. (c) Rectangle. (d) Rounded rectangle (oval), called a terminal.
3. State a benefit and a drawback of using a flowchart rather than pseudocode.
Show answer
Advantage: the flow of control (decisions and loops) is easy to see visually. Disadvantage: flowcharts take longer to draw and change, and become large for long algorithms.
4. Why is narrative not usually used for the final design of a program?
Show answer
Everyday language can be ambiguous and imprecise, decisions and loops are hard to see, and it is further from program code, so the programmer may interpret it differently from what was intended.
5. In a flowchart, how can you tell the difference between a decision used for selection (IF) and one used for a loop?
Show answer
For selection, both exits continue downwards and join again later. For a loop, one path leads back up to the decision (or to before it), so the steps repeat.
6. Write pseudocode for: input a temperature; if it is above 37.5, output "Fever", otherwise output "Normal".
Show answer
INPUT temp
IF temp > 37.5 THEN
OUTPUT "Fever"
ELSE
OUTPUT "Normal"
ENDIF
7. Convert into a narrative: count ← 0; FOR i ← 1 TO 5 DO INPUT x; IF x < 0 THEN count ← count + 1 ENDIF ENDFOR; OUTPUT count
Show answer
Set the count to 0. Read five numbers one at a time; each time a number is negative, add 1 to the count. After the fifth number, display the count (the number of negative values).
8. A student’s flowchart has a decision with three arrows leaving it, labelled "<", "=" and ">". What rule does this break, and how should it be fixed?
Show answer
A decision must have exactly two exits (Yes/No). Use two decisions: first test x < y (Yes → the "<" path); on No, test x = y (Yes → the "=" path; No → the ">" path).
Homework
- Write a narrative, pseudocode and a flowchart for: input the price of an item and the amount paid; if the amount is enough, output the change, otherwise output how much more is needed.
- Convert the courier pseudocode in Part 4 into a narrative of no more than four sentences.
- Draw a flowchart for: keep reading numbers until -1 is entered, then output the largest number read. Label every decision exit.
- In Try it 2, choose Other marks and predict the final value of passes before you step through. Which mark tests the boundary?
- Change
passes.cso that it also counts merits (70 or more). Update the pseudocode and the flowchart to match your program.
Optional video: Understanding and Writing Flowcharts (MrBrownCS, YouTube). a clear walk-through of flowchart symbols and how to build a flowchart for a simple algorithm.
Mastery quiz: Representing Algorithms
This 10-question quiz is separate from the short Quick quiz at the end of the lesson. Score 8/10 or higher to earn this lesson’s badge. Your best score is saved in this browser on this device.
Mastery quiz: Representing Algorithms: Narrative, Flowcharts and Pseudocode
Your course badges: loading saved progress…
View badges
No course badges earned yet. Score 8/10 in a lesson quiz to earn its badge.
Saved in this browser on this device. Clearing browser data may remove your badges.
Answer all 10 questions. Earn this lesson’s badge at 8/10 or higher. Read the explanations, revisit the Try it activities and retry as often as you need. These are self-study badges, not formal grades.
Exam tips
Specimen Unit 1 Paper 01 (2021), Items 16 and 30. Multiple-choice items on representing algorithms graphically and on what a particular flowchart symbol means. Learn the seven symbols in Part 3, including the less common connector and predefined process.
Specimen Unit 1 Paper 02 (2021), Question 4(a). Drawing a flowchart from given pseudocode. Use the pseudocode-to-flowchart steps in Part 6: one symbol per line, two labelled exits on every diamond, a back-arrow for each loop, and a single Start and Stop.
CAPE 2024 Unit 1 Paper 02, Question 3(b)(ii). A flowchart with nested decisions for a rate calculation, similar in shape to the courier example. Put each later decision on the No path of the earlier one, and make sure every branch joins before the output. A worked answer is linked in the Go further box.
CAPE 2012 Unit 1 Paper 02, Question 3(c) and (d). Writing pseudocode and drawing a flowchart for the same problem. Make the two agree exactly, especially at boundary values (≥ or >).
More worked answers are on the CS Solutions page.
Previous: Module 2 • Lesson 04 – Well-Designed Algorithms and Their Properties. Next: Module 2 • Lesson 06 – Sequence, Input, Output and Assignment.
Syllabus link: CAPE Computer Science (CXC A19/U2/21), Problem-Solving with Computers (Unit 1, Module 2). Specific Objective 5: identify ways of representing algorithms (narrative, flowcharts and pseudocode).
Try it 4Quick quiz
Tap an answer. All eight questions are self-checks on this lesson.
Updates
2026/12/01
- Updated the copyright line.
- Published. Previous/Next links and the mastery quiz links now use the full lesson addresses.
- Small script tidy-up for the site (no change to how the activities work).
2026/11/24
- Linked Previous/Next and the mastery quiz URLs to draft shortlinks (?p=ID), which will redirect to the permalink after publish.
- First version of the lesson.
© 2026 islandclass.org
