Flowcharts and Pseudocode: Sequence, Selection and Loops

Now that you know what an algorithm is, you need to be able to write one the way CSEC expects – as a flowchart or in pseudocode. This post covers the flowchart symbols, the pseudocode keywords, and the control structures: sequence, selection and loops (repetition).

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Flowchart symbols
  • Pseudocode keywords
  • Sequence
  • Selection: IF-THEN, IF-THEN-ELSE and nested IF
  • Loops: FOR, WHILE and REPEAT-UNTIL

Video: Computer Science Basics: Sequences, Selections, and Loops – https://www.youtube.com/watch?v=eSYeHlwDCNA

Flowchart symbols

Start / StopTerminator – start or endInput / OutputInput/Output – read or displayProcessProcess – calculation or assignmentDecision?Decision – a yes/no questionFlow line – shows the direction
The flowchart symbols you need for CSEC.
A simple flowchart for fixing a lamp that does not work. The diamonds are decisions (yes/no questions) and the rectangles are actions.
A simple flowchart for fixing a lamp that does not work. The diamonds are decisions (yes/no questions) and the rectangles are actions.

Image source: File:LampFlowchart.svg

Pseudocode keywords

  • Input: READ or INPUT
  • Output: PRINT, WRITE, OUTPUT or DISPLAY
  • Storing a value (assignment): STORE, or an arrow such as total ← 0 (some teachers use =)
  • Decisions: IF … THEN … ELSE … ENDIF
  • Loops: FOR … ENDFOR, WHILE … ENDWHILE, REPEAT … UNTIL

Sequence

In a sequence, the steps are carried out one after another, in order. Example: find the average of three test scores.

Pseudocode

START
    READ score1, score2, score3
    average ← (score1 + score2 + score3) / 3
    PRINT "The average is ", average
STOP
StartInput score1, score2, score3average ← (s1 + s2 + s3) / 3Output averageStop
Flowchart for the average of three scores (sequence).

Selection

Selection lets the algorithm make a decision and choose which steps to carry out.

IF-THEN-ELSE

START
    READ mark
    IF mark >= 50 THEN
        PRINT "Pass"
    ELSE
        PRINT "Fail"
    ENDIF
STOP
StartInput markmark >= 50?YesNoOutput "Pass"Output "Fail"Stop
Flowchart for the Pass/Fail decision. A decision diamond has two exits: Yes and No.

A nested IF is an IF inside another IF. It is used when there are more than two choices, such as grades:

Nested IF

READ mark
IF mark >= 75 THEN
    PRINT "Grade A"
ELSE
    IF mark >= 60 THEN
        PRINT "Grade B"
    ELSE
        PRINT "Grade C"
    ENDIF
ENDIF

Loops (repetition)

A loop repeats a set of steps. CSEC uses three kinds:

  • FOR loop – repeats a known number of times (counter-controlled).
  • WHILE loop – checks a condition first, and repeats while it is true. It may run zero times.
  • REPEAT-UNTIL loop – does the steps first, then checks the condition at the end, so it always runs at least once.

FOR loop: add up 5 prices

total ← 0
FOR count ← 1 TO 5 DO
    READ price
    total ← total + price
ENDFOR
PRINT "Total: ", total
Starttotal ← 0, count ← 1count <= 5?YesInput pricetotal ← total + pricecount ← count + 1NoOutput totalStop
Flowchart for the FOR loop above. The arrow going back up shows the repetition.

WHILE loop: keep going until -1 is entered (a sentinel or rogue value)

READ mark
WHILE mark <> -1 DO
    IF mark >= 50 THEN
        PRINT "Pass"
    ELSE
        PRINT "Fail"
    ENDIF
    READ mark
ENDWHILE

REPEAT-UNTIL loop: ask for the PIN until it is correct

REPEAT
    READ pin
UNTIL pin = 1234
PRINT "Welcome"

Algorithm and program side by side

Here is a loop like the FOR example turned into real programs (the number of items is read first, and VAT is added as a constant). You will learn how to do this translation in Section 8.

Python

# Total a shopping bill and add VAT
VAT_RATE = 0.125          # constant: 12.5% VAT

num_items = int(input("How many items? "))
subtotal = 0.0
for i in range(num_items):
    price = float(input("Enter price: $"))
    subtotal = subtotal + price
vat = subtotal * VAT_RATE
total = subtotal + vat
print("Subtotal: $" + format(subtotal, ".2f"))
print("VAT: $" + format(vat, ".2f"))
print("Total: $" + format(total, ".2f"))

C

/* Total a shopping bill and add VAT */
#include <stdio.h>

#define VAT_RATE 0.125    /* constant: 12.5% VAT */

int main(void)
{
    int num_items, i;
    float price, subtotal = 0.0, vat, total;

    printf("How many items? ");
    scanf("%d", &num_items);
    for (i = 1; i <= num_items; i++)
    {
        printf("Enter price: $");
        scanf("%f", &price);
        subtotal = subtotal + price;
    }
    vat = subtotal * VAT_RATE;
    total = subtotal + vat;
    printf("Subtotal: $%.2f\n", subtotal);
    printf("VAT: $%.2f\n", vat);
    printf("Total: $%.2f\n", total);
    return 0;
}

Sample run: 3 items costing 25, 40.50 and 10 → Subtotal: $75.50, VAT: $9.44, Total: $84.94.

Try it: Flowchart symbol and control structure matcher

Choose the correct answer for each.

Shape used for “Input price”
Shape used for “total ← total + price”
Shape used for “Is mark >= 50?”
Shape used for “Start” and “Stop”
Loop that repeats a known number of times
Loop that always runs at least once
Loop that checks its condition before running

Related

Related:
• Ways of representing algorithms
• Closure on Sequence with flow charts
• Flowchart Practise – Finding the average of 3 numbers.
• Selection Statements: Practise Exercise(s)
• Using multiple selection statements (By Example)

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. Which flowchart symbol is used for a decision?
(A) Rectangle
(B) Parallelogram
(C) Diamond
(D) Oval

2. Which pseudocode keyword is used to accept data from the user?
(A) PRINT
(B) READ
(C) STORE
(D) ENDIF

3. Which loop is BEST when you know exactly how many times to repeat?
(A) WHILE
(B) REPEAT-UNTIL
(C) FOR
(D) IF-THEN

4. A REPEAT-UNTIL loop differs from a WHILE loop because it
(A) never ends
(B) checks the condition at the end, so it runs at least once
(C) cannot contain IF statements
(D) runs exactly 10 times

5. Carrying out instructions one after the other in order is called
(A) selection
(B) iteration
(C) sequence
(D) nesting

Show answers

1. C
2. B
3. C
4. B
5. C

Paper 2 practice (structured question)

A school canteen gives a 10% discount on any lunch order costing more than $50. Otherwise there is no discount.

(a) Name the flowchart symbol used for EACH of the following:

(i) reading the cost of the order (1 mark)

(ii) checking whether the cost is more than $50 (1 mark)

(b) Write pseudocode to read the cost of ONE order and print the amount to pay after any discount. (5 marks)

(c) State the type of loop you would use to process orders until a cost of 0 is entered, and give ONE reason. (2 marks)

(d) Distinguish between sequence and selection. (2 marks)

Total: 11 marks

Show answers

(a)

(i) Parallelogram / input-output symbol (1 mark)

(ii) Diamond / decision symbol (1 mark)

(b) One mark for each marked line:

READ cost                            (1 mark)
IF cost > 50 THEN                    (1 mark)
    amount ← cost − (cost × 0.10)    (1 mark)
ELSE
    amount ← cost
ENDIF                                (1 mark for ELSE … ENDIF)
PRINT amount                         (1 mark)

(c) WHILE (or REPEAT-UNTIL) loop (1 mark); the number of orders is not known in advance, so the loop must stop when the sentinel value 0 is entered (1 mark).

(d) Sequence: instructions are carried out one after another in order (1 mark). Selection: a condition is tested and a choice is made about which instructions to carry out (1 mark).

Next: Operators in Algorithms: Arithmetic, Relational and Logical Operators, Truth Tables, MOD and DIV

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 6 (“represent algorithms in the form of flowchart and pseudocode”).

Attributions to media used in this post:

Updates

2026/10/16

– Syntax highlighting added to code examples.

© 2026 Vedesh Kungebeharry. All rights reserved.

What Is an Algorithm? Definition and Characteristics of a Good Algorithm

You follow algorithms every day – a recipe for coconut bake, the steps to top up your phone credit, or directions to a friend’s house. In this post we look at what an algorithm is and the characteristics every good algorithm must have.

Build on what you learned in Forms 1–3

These Lower School ICT posts cover the basics of this topic:

In this post:

  • Definition of an algorithm
  • Characteristics of a good algorithm
  • Good vs bad algorithm examples
  • Ways of representing an algorithm

Video: Computer Science Basics: Algorithms – https://www.youtube.com/watch?v=kM9ASKAni_s

What is an algorithm?

An algorithm is a finite sequence of clear, step-by-step instructions for solving a problem or completing a task. A computer program is an algorithm written in a programming language so that a computer can follow it.

Characteristics of a good algorithm

The CSEC syllabus expects you to know that an algorithm:

  • has a finite number of steps – it does not go on forever;
  • is precise – each step is exact (e.g. “add 2 cups of flour”, not “add some flour”);
  • is unambiguous – each step has only one meaning, so everyone following it does the same thing;
  • has a flow of control from one process to another – the steps happen in a clear order; and
  • terminates – it comes to an end and produces a result.

Good and bad examples

Not a good algorithm stepWhyBetter version
Add sugar to tasteNot precise – how much?Add 2 tablespoons of sugar
Keep stirringNever ends – not finiteStir for 3 minutes
Turn at the big treeAmbiguous – which tree? which way?Turn left at the mango tree opposite the church

Example: topping up phone credit

  1. Start
  2. Dial the top-up code
  3. Enter the 16-digit voucher number
  4. Press Send
  5. Read the confirmation message
  6. Stop

This algorithm is finite (6 steps), precise, unambiguous, flows from one step to the next and terminates.

Ways of representing algorithms

Algorithms can be written as narrative (plain sentences), pseudocode (structured English-like statements) or as a flowchart (a diagram). CSEC focuses on pseudocode and flowcharts – see the next post and the earlier post Ways of representing algorithms.

Optional extension: famous algorithms such as sorting and finding the shortest route – the idea behind map apps.

Video: Intro to Algorithms: Crash Course Computer Science #13 – https://www.youtube.com/watch?v=rL8X2mlNHPM

Try it: Which characteristic is missing?

Each instruction breaks one characteristic of a good algorithm. Choose which one.

“Repeat forever: wipe the table”
“Pour in a little milk”
“Go to the shop by the school” (there are two schools nearby)
Steps are jumbled with no clear order

Related

Related:
• WHAT IS AN ALGORITHM? – DEFINITION
• Algorithms
• The purpose of an algorithm

Paper 1 practice (multiple choice)

Choose the best answer for each question. Try them all before you check.

1. An algorithm is BEST defined as
(A) a computer program in machine code
(B) a finite set of step-by-step instructions to solve a problem
(C) a diagram of computer hardware
(D) a programming language

2. “Bake until it looks nice” is NOT a good algorithm step because it is not
(A) finite
(B) precise
(C) a flowchart
(D) a program

3. Which characteristic means an algorithm must eventually stop?
(A) Unambiguous
(B) Terminates
(C) Precise
(D) Flow of control

4. Which is NOT a way of representing an algorithm?
(A) Pseudocode
(B) Flowchart
(C) Narrative
(D) Compiler

5. Each instruction in an algorithm should have only one meaning. This is called being
(A) finite
(B) unambiguous
(C) efficient
(D) terminated

Show answers

1. B
2. B
3. B
4. D
5. B

Paper 2 practice (structured question)

Shania writes these instructions for her younger brother to make a cup of cocoa tea: “Boil some water. Put cocoa in the cup. Add the water. Stir for a while. Add sugar if you want.”

(a) Define the term “algorithm”. (2 marks)

(b) State THREE characteristics of a good algorithm. (3 marks)

(c) Identify TWO steps in Shania’s instructions that are not precise and rewrite EACH so that it is precise. (4 marks)

(d) Name ONE way, other than narrative, to represent an algorithm. (1 mark)

Total: 10 marks

Show answers

(a) A finite sequence of step-by-step instructions (1 mark) for solving a problem or completing a task (1 mark).

(b) Any three (1 mark each):
• finite number of steps
• precise
• unambiguous
• flow of control from one process to another
• terminates

(c) Any two steps identified (1 mark each) with a precise rewrite (1 mark each), e.g.
• “Boil some water” → “Boil 1 cup of water”
• “Stir for a while” → “Stir for 30 seconds”
• “Put cocoa in the cup” → “Put 2 teaspoons of cocoa in the cup”

(d) Pseudocode OR flowchart (1 mark).

Next: Flowcharts and Pseudocode: Sequence, Selection and Loops

Syllabus link: This post is relevant to the CSEC® Information Technology Syllabus (CXC 30/G/SYLL 17), Section 7: Problem-Solving and Program Design, Specific Objective 5 (“explain the concept of algorithms”).

Attributions to media used in this post:

No third-party images are used in this post. Embedded videos are credited on YouTube to their channels.

© 2026 Vedesh Kungebeharry. All rights reserved.

The Game Design Process: Brainstorming, Rapid Prototyping, Playtesting and RAD vs Waterfall

The game design process is the set of stages a team goes through to turn an idea into a finished game. Most modern game teams use an iterative process: they build a small version of the game, test it with players, improve it, and repeat until the game is fun. A popular approach built on this idea is Rapid Application Development (RAD).

Stage 1: The creative process

Every game starts with ideas:

  • Brainstorming – a group discussion where everyone suggests ideas freely, without judging them at first.
  • Ideation – developing, combining and choosing the best ideas, then describing the core concept (for example: “a puzzle game where you rotate the world to guide a ball home”).

Stage 2: The iterative process

Instead of planning everything and building the whole game at once, the team works in short cycles:

  1. Rapid prototyping – quickly conceptualise, design, code and test a rough playable version (a prototype). Prototypes can even be made with paper, cards and dice before any code is written.
  2. Play test – real players try the prototype while the team watches and takes notes. Is it fun? Confusing? Too hard? Are there bugs?
  3. Revision – change the design based on what was learned: fix problems, remove what does not work and improve what does.
  4. Repeat – build the next version and test again. Each cycle is called an iteration.
Iterative development cycle diagram
Figure 1 – An iterative development cycle: after initial planning, the team repeatedly plans, designs, implements, tests and evaluates, and deploys when the product is ready.
Paper prototype of a game with cards and a hand-drawn board
Figure 2 – A paper prototype made by game designer Jason Rohrer while developing his video game Diamond Trust of London (released 2012).
People playtesting a card game at a game jam
Figure 3 – Game jam participants playtesting a new game.

What is RAD?

Rapid Application Development (RAD) is an approach to software development that puts less emphasis on detailed planning up front and more on building working prototypes quickly and changing requirements as the team learns. The term is also linked to James Martin, who described a RAD method in the early 1990s. In games, RAD fits naturally with rapid prototyping and playtesting.

Plan-based methods: the waterfall model

Plan-based methods do most of the planning before development begins. The best-known is the waterfall model, where each stage is finished before the next one starts: requirements, design, implementation, verification (testing) and maintenance.

Waterfall model diagram
Figure 4 – The waterfall model: each stage flows down into the next.

RAD vs waterfall

RAD / iterativeWaterfall
PlanningLight planning at the start, refined as you goDetailed planning at the start
ChangeChanges are expected and welcomedChanges are difficult and costly later on
TestingEarly and often, with real playersMainly near the end
Working versionAvailable early (prototypes)Only near the end
Best forProjects where the “fun” must be discovered, such as gamesProjects with clear, fixed requirements

Advantages of RAD in game design

  • Problems and boring gameplay are found early, when they are cheaper to fix.
  • Player feedback shapes the game, so it is more likely to be enjoyable.
  • The team always has something playable to show to publishers, investors or clients.
  • It is flexible when ideas, technology or the market change.

Disadvantages of RAD

  • Without discipline, the project can keep growing (“scope creep”) and miss deadlines.
  • It needs regular involvement from testers and decision-makers.
  • Quick prototype code may be messy and need rewriting.
  • It can be harder to predict the final cost and finish date at the start.

Example

Our Scratch game tutorial builds a game step by step, testing after each part, which is a small example of iteration: A simple game! For a team project, try Group Project – Create a Game in Scratch!

Video

Game Maker’s Toolkit explains why and how to prototype a game, including quick paper prototypes, before building the full thing.

Exercise

  1. In a group, brainstorm at least 10 game ideas in 10 minutes. Choose one and describe its core concept in one sentence.
  2. Make a paper prototype of your idea and play test it with another group. Write down three changes you would make.
  3. Explain why an iterative (RAD) approach is often better than the waterfall model for making games.
  4. Give one situation where the waterfall model might be a better choice.

Syllabus link: This post is relevant to the CAPE® Animation and Game Design Syllabus, Unit 1: Fundamentals of Animation and Game Design, Module 1: Understanding Animation and Game Design – Specific Objective 21 (“identify the main stages of game design”); Specific Objective 22 (“explain the importance of RAD in game design”).

Attributions to media used in this post:

Iterative development model.svg – Aflafla1 – CC0 (via Wikimedia Commons)

Diamond Trust of London – Paper Prototype.jpg – Jason Rohrer – Public domain (via Wikimedia Commons)

WikiGameJam SF 2025 – Playtesting.jpg – Kevin Payravi – CC BY-SA 4.0 (via Wikimedia Commons)

Waterfall model.svg – Peter Kemp / Paul Smith – CC BY 3.0 (via Wikimedia Commons)

© 2026 Vedesh Kungebeharry. All rights reserved.

Algorithms

Definition: An algorithm is a set of finite, well defined steps which outlines the solution to a specific problem.

Alternative Definition : WHAT IS AN ALGORITHM? – DEFINITION

We use algorithms every day to solve problems, weather we’re conscious of it or not.

When we cook a new dish we follow a recipe, when we solve a math problem we follow a procedure.

In our case, we’d like to document the solution to a specific problem using an algorithm so that we can communicate it to a programmer , or create the tool  as a program itself.

We use algorithms, but what are the properties of a good algorithm?

I’m sure you’ve come across bad algorithms already –

  • Vague recipe instructions, what exactly is 2 cups of flour?
  • A videogame walkthrough that isn’t descriptive enough
  • A video tutorial that talks  a lot about becoming a youtuber , but the steps aren’t outlined in order.

What are the properties of good instructions, good algorithms?

Properties of good algorithms

  • Has a  finite number of steps ( a definite beginning and an end)
  • Is precise,
  • Is unambiguous (not subject to interpretation)
  • Shows the flow of control from one sub-process to another
  • Must output results
  • It must terminate.

© 2021  Vedesh Kungebeharry. All rights reserved. 

Algorithms In Narrative Form

An algorithm in narrative form is not written in discrete steps.   It is expressed as directions in paragraph form and instructions on how rules should be followed.

An algorithm in narrative form can be considered a precursor to pseudocode or a flowchart

Example

An example is given below for the given problem statement

Problem Definition: A solution is needed which finds the circumference of a circle.

Algorithm in narrative form: Prompt the user to enter a non-negative value for the radius and store it. If the radius entered is negative or is not a number, keep on prompting the user and accept values until a suitable value is entered.  Use the formula C=2*3.14* r to calculate and store the circumference. Output the circumference to the user and stop processing.

In class exercise

Write an algorithm in narrative form which gives instructions/directions on how to follow the rules in order to play “Snakes and ladders”.

© 2020  Vedesh Kungebeharry. All rights reserved. 

WHAT IS AN ALGORITHM? – DEFINITION

An algorithm is a well-defined, precise, finite set of steps for solving a problem.

What do those words mean?

  • Well-defined and precise: each step is clear and exact. The person (or computer) following it never has to guess what to do.
  • Finite: the algorithm must end. It cannot go on forever.
  • Steps: the instructions are carried out one at a time, in the correct order.

Algorithms in everyday life

You already use algorithms every day. A recipe is an algorithm! Here is an algorithm for making a cup of tea:

  1. Boil some water. (Ask an adult to help with hot water.)
  2. Put a teabag into a cup.
  3. Pour the hot water into the cup.
  4. Wait 3 minutes.
  5. Take out the teabag.
  6. Add milk and sugar if you like.
A teabag being lifted out of a white cup of tea
Step 5: take out the teabag. Credit: Pasi Mammela, CC BY-SA 2.0, via Wikimedia Commons

Notice that the steps are clear, they are in order, and they end with a cup of tea. That makes it an algorithm.

Ways to write an algorithm

  • Narrative: the steps are written in ordinary sentences, like a story.
  • Pseudocode: the steps are written in short, code-like statements such as IF, THEN and PRINT.
  • Flowchart: the steps are drawn as shapes joined by arrows.

Here is a simple flowchart for fixing a lamp that does not work. Follow the arrows from the top. The diamond shapes are questions: you go one way for “Yes” and another way for “No”.

Flowchart: Lamp doesn't work. Lamp plugged in? No: plug in lamp. Yes: Bulb burned out? Yes: replace bulb. No: repair lamp.
A flowchart for a lamp that doesn’t work. Credit: Booyabazooka (SVG) and Wapcaplet (original PNG), CC BY-SA 3.0, via Wikimedia Commons

Related lessons on this site

Quick check

  1. What does it mean for an algorithm to be finite?
  2. Write an algorithm, as numbered steps, for brushing your teeth.
  3. Name three ways to write an algorithm.

Attributions to media used in this post

© 2020 Vedesh Kungebeharry. All rights reserved.

Updates to this post: October 2026 – Added explanations, examples, a flowchart and a quick check.

The Importance of algorithms

In our discussion, we consider well defined precise algorithms (in flowcharts or pseudocode) as compared with narrative algorithms.

Some of the reasons why algorithms are beneficial or important to the problem solving process are:

  1. Algorithms serve as a blueprint for other programmers to follow

  2. When problems are complex, an algorithm’s precise structure allows for an accurate development of a solution in parts.  This documentation (the algorithm itself) is useful since it is difficult for  the problem solver to remember many sub-processes , procedures and inputs/outputs to the problem.

  3. Because algorithms are intended for a computer system and programming language, it allows us to design for that particular programming language’s structure and for efficiency ,given    the limitations of system resources.

    For example, an algorithm which processes DNA sequence information for matching DNA strands together (see Longest common sub sequence) can be developed strictly for solving the problem without considering system resources.   In this case the algorithm still resembles programming language. 

    Usually in this type of general solution, array sizes are allowed to be very large or of infinite size. If memory becomes a constraint, we can now modify the algorithm to use say, array sizes at a maximum of  1000 to allow for the intended program to run within the limitation of our system resources.

  4. Algorithms are easily testable when using dry runs and trace tables.

© 2019  Vedesh Kungebeharry. All rights reserved.