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.

Pseudocode in Your Assignmentยถ

What 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:

Annotating Pseudocodeยถ

Pseudocode in your assessments should not stand alone. Annotations โ€” short explanatory notes attached to your pseudocode โ€” provide evidence across multiple criteria, not just Communicating.

What criteria do annotations evidence?ยถ

IA1

IA2 and IA3

What annotations should sayยถ

The focus of annotations differs slightly across each assessment.

IA1 โ€” Technical Proposal

In IA1, pseudocode represents proposed algorithms that do not yet exist as working code. Annotations should:

IA2 โ€” Digital Solution

In IA2, pseudocode and annotated code represent programmed components of your working prototype. Annotations should:

IA3 โ€” Digital Solution (Data Exchange)

IA3 has a strong focus on data exchange and security. Annotations should:

How to format annotationsยถ

Annotations can be added:

Keep annotations concise and specific. An annotation that says โ€œthis loop iterates through the recordsโ€ adds nothing โ€” the pseudocode already shows that. A useful annotation explains why, or links to a criterion:

Weak annotationStrong annotation
This loop reads each recordReads each student record to validate the score against the pass threshold โ€” addresses SC3: data validation
This function validates inputPrevents empty strings being written to the database, supporting data integrity (SC2)