Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Pseudocode 📝

Learning Goals

By the end of this section you will:

good code

Pseudocode is a simplified way of writing out the steps of an algorithm without worrying about the rules of a specific programming language.

It helps programmers:

Key advantages:

QCAA Pseudocode Rules

In Digital Solutions, pseudocode is the standard way to represent algorithms. Since schools use different programming languages, the syllabus uses pseudocode to ensure consistency. The QCAA has set specific rules for how it must be written.

Keywords

KEYWORDS should be written bold and capitalized.

Keywords do not have to be valid programming language words as long as they clearly convey the intent of the line of pseudocode.

Calculations

Pseudocode should clearly indicate what is happening at each step, including formulas of calculations.

For example: CALCULATE net is not as clear as CALCULATE net = gross − tax

Naming Conventions

Use snake case naming convention for variable names with multiple words, subroutines, methods and functions.

Snake case is a convention where all words are in lowercase and spaces between words is replaces with an _

For example: VAR file_name

Font

Use a mono-space typeface when writing algorithms on computer:

Windows mono-space fonts:

Mac mono-spaced fonts:

Variables

To input or output values, common words can be used as keywords.

For example:

Pseudocode uses the assignment operator, = to assign values.

For example:

Modularisation

All pseudocode modules start and ends with the BEGIN and END keywords.

Main algorithm:

BEGIN
    statements
END

Defining procedures, subroutines, methods or functions

BEGIN function_name
    statements
END

Calling procedures, subroutines, methods or functions

statements
function_name
statements

Iterations

There are three main types of loops — each has a clear start and end, with the statements within the loop indented.

Post-test loops

REPEAT
    statements
UNTIL condition

Pre-test loop

WHILE condition
    statements
ENDWHILE

Counted loop

FOR count = start_val TO end_val
    statements
NEXT count
ENDFOR

Selection

A control structure used for decisions or branching and choosing alternate paths. The beginning and end of these structures are indicated with keywords.

IF statement

IF condition THEN
    statements
ENDIF

IF...ELSE statement

IF condition THEN
    statements
ELSE
    statements
ENDIF

IF...ELIF...ELSE statement

IF condition THEN
    statements
ELSE IF condition THEN
    statements
ELSE
    statements
ENDIF

MATCH statement

In most other languages these are called switches

SWITCH test_variable
    CASE option
        statements
    CASE option
        statements
    CASE option
        statements
ENDSWITCH

SQL

The QCAA does not have any opinion about the pseudocode for SQL. Therefore, just write your SQL code like you would use it in your program.

What Pseudocode to Include

Your assignment have limited space, so you will not be able include all your algorithms as pseudocode. That presents the question, what code should you include?

Ultimately, the pseudocode presented in your assignment should demonstrate your coding skill. Choose the algorithms that you are most proud of, or that you found the trickiest.

Also keep in find that you should be demonstrating all six of the algorithm basic building blocks: