What is pseudocode?
Pseudocode is a way of designing an algorithm using structured, plain-English statements that look like code but do not follow the strict syntax of any one programming language. Each line is numbered and uses clear keywords for input, selection, loops and output. It lets you plan logic before coding. Example: Design input validation for a mark between 0 and 100. 1. Receive mark from keyboard 2. WHILE mark < 0 OR mark > 100 DO 3. Send error message to display 4. Receive mark from keyboard 5. END WHILE Answer: The loop repeats until a valid mark is entered.
In SQA Higher Computing Science, pseudocode is one of the accepted design notations, alongside structure diagrams and flowcharts. Good pseudocode is numbered, refines each main step, and makes the control structures, such as conditional loops, clear enough to implement in any language.
Worked example
Write pseudocode to validate that a mark entered is between 0 and 100.
- Get the first input: receive mark from keyboard.
- Use a conditional loop: WHILE mark < 0 OR mark > 100.
- Inside the loop, show an error message.
- Inside the loop, ask for the mark again.
- End the loop: the mark is now valid.
Answer: A WHILE loop that repeats the input until 0 ≤ mark ≤ 100 validates the mark.
Want one-to-one support?
One-to-one online tuition can help you build confidence in your subject. Find a tutor who teaches your course.
Find a TutorLearn face to face in Glasgow
Prefer in-person lessons? Visit the ExpertTutor Glasgow Southside centre.
See the centre