Pseudocode (SQA National 5 Computing Science): Revision Note
Exam code: X816 75
Pseudocode
What is pseudocode?
Pseudocode is a text-based way of describing the steps in an algorithm
It uses short English statements to show what the program should do, without using the full syntax of a programming language
Pseudocode is structured and logical, helping you plan your solution before coding it
Example
A website wants a program that asks users to enter their age
If they are 18 or over, they are allowed to enter the site
If they are under 18, they are shown a suitable message
RECEIVE age FROM KEYBOARD
IF age >= 18 THEN
SEND "Welcome to the site" TO DISPLAY
ELSE
SEND "Sorry, this site is for users aged 18 and over" TO DISPLAY
END IFThe program asks the user to enter their age
The value entered is stored in a variable called
ageThe IF statement checks whether the user is 18 or older
If the condition is true, the message “Welcome to the site” is displayed
If the condition is false, the message “Sorry, this site is for users aged 18 and over” is displayed
The program then ends after showing the correct message
Examiner Tips and Tricks
Do not use real code syntax like
print()orinput()Use SQA pseudocode keywords such as:
RECEIVE ... FROM KEYBOARDSEND ... TO DISPLAY
Indent your code inside
IF,REPEAT, andWHILEblocks to make it clearWrite pseudocode, not English sentences, keep it structured and consistent
Example (refined version)
The website now wants the program to ask for the user’s first name and use it to greet them
RECEIVE firstName FROM KEYBOARD
RECEIVE age FROM KEYBOARD
IF age >= 18 THEN
SEND "Welcome to the site " & firstName TO DISPLAY
ELSE
SEND "Sorry, this site is for users aged 18 and over" TO DISPLAY
END IFThe program first asks for the user’s first name and stores it in
firstNameIt then asks for the user’s age and stores it in
ageThe IF condition checks whether the age entered is 18 or more
If it is, the program joins (“concatenates”) the text “Welcome to the site” with the user’s name and displays it, for example:
Welcome to the site Sarah
If the age is under 18, the program displays the same rejection message as before
The program then ends
Examiner Tips and Tricks
If you’re asked to design an algorithm, use pseudocode by default
Only use flowcharts if the question specifically asks for one or if you find it easier to show logic visually
Clarity is more important than fancy formatting
Unlock more, it's free!
Did this page help you?