Pseudocode
Most programs are developed using programming languageA language used by a programmer to write a piece of software. . These languages have specific syntaxRules governing how to write statements in a programming language. that must be used so that the programSequences of instructions for a computer. will run properly. pseudocode Also written as pseudo-code. A method of writing up a set of instructions for a computer program using plain English. This is a good way of planning a program before coding. is not a programming language, it is a simple way of describing a set of instructionA single action that can be performed by a computer processor. that does not have to use specific syntax.
Common pseudocode notation
There is no strict set of standard notationA system of written symbols or graphics used to represent something in order to aid communication and understanding. for pseudocode, but some of the most widely recognised are:
- INPUT 鈥 indicates a user will be inputting something
- OUTPUT 鈥 indicates that an output will appear on the screen
- WHILE 鈥 a loopA method used in programming to repeat a set of instructions. (iterationIn computer programming, this is a single pass through a set of instructions. that has a conditionIn computing, this is a statement or sum that is either true or false. A computation depends on whether a condition equates to true or false. at the beginning)
- FOR 鈥 a counting loop (iteration)
- REPEAT 鈥 UNTIL 鈥 a loop (iteration) that has a condition at the end
- IF 鈥 THEN 鈥 ELSE 鈥 a decision (selectionA decision within a computer program when the program decides to move on based on the results of an event.) in which a choice is made
- any instructions that occur inside a selection or iteration are usually indented
Using pseudocode
Pseudocode can be used to plan out programs. Planning a program that asks people what the best subject they take is, would look like this in pseudocode:
REPEAT
OUTPUT 'What is the best subject you take?'
INPUT user inputs the best subject they take
STORE the user's input in the answer variable
IF answer = 'Computer Science' THEN
OUTPUT 'Of course it is!'
ELSE
OUTPUT 'Try again!'
UNTIL answer = 'Computer Science'