top of page

Pseudocode

## Pseudocode

Pseudocode is not a specific programming language but a more general method of describing instructions. It should be unambiguous, and it should not resemble any particular kind of programming language (e.g. Python or Java), so it can theoretically be turned into real code in any language.

â€‹

Generally, pseudocode can be written in any way that is readable and clearly shows its purpose. However, the Eduqas exam board advises that pseudocode for the programming exam should follow the conventions below:

Annotation

{Write your comment in curly brackets}

â€‹

Define data type

price is integer

firstname is string

â€‹

Declare a variable's value

set price = 100

set firstname = "Marcella"

â€‹

Input / output

output "Please enter your first name"

input firstname

Selection (must have indentation)

if firstname = "Steven" thenâ€‹

output "Hello" + firstname

elif firstname = "Steve" then

output "Please use full name"

else output "Who are you?"

end if

â€‹

Iteration (while loop)

while firstname != "Steven"

output "Guess my name."

input firstname

repeat

Iteration (for loop)

for i in range 10

input item

next i

â€‹

Define a subroutine

Declare Sub1

[Subroutine content indented]

End Sub1

â€‹

Call a subroutine

call Sub1

## Flowcharts

flowchart

A flowchart can be used to visually represent an algorithm. The flowchart symbols are:

## Algorithm Example

example

Pseudocode

{This is a program to see how many items you can buy in a supermarket
before you spend over £100}

â€‹

total is integer, itemsentered is integer, itemprice is integer

set total = 0

set itemsentered = 0

â€‹

while total < 100

output "enter the price of the next item"

input itemprice

total = total + itemprice

itemsentered = itemsentered + 1

repeat

if itemsentered >= 20 then

output "You are on your way to saving money."

elif itemsentered => 30 then

output "You're a real money saver."

else output "Look for better deals next time."

end if

Stop

Flowchart

bottom of page