Whether algorithms are designed with pseudo-code or flowcharts, the focus is on the logic of the steps instead of the programming language because programmers should be able to translate an algorithm into any programming language, for example, from Python to C++. This is known as being language independent.
Pseudo-code is a simple way of describing a set of instructions in a manner that resembles a programming language. In an algorithm, most processes fall into three main categories:
When pseudo-code is being written, inputs, processes and outputs can be identified using the key words in the code.
For example, if a person was writing a program where a number is input and the program calculates and outputs the times table up to ten, they could write a statement like this:
The user INPUTS a number which is saved as num FOR each number from 1 to 10, OUTPUT num*number
This could be improved by writing the pseudocode:
num ← USERINPUT FOR number ← 1 TO 10 OUTPUT number * num ENDFOR
← symbol in pseudo-code means assignment. Most programming languages use = instead of
←. In the example above,
num ← USERINPUT means that the user input is being put into, or assigned to, the variable called
Outputs use the word
OUTPUT before the data to be sent to the user. In the example above, the line
OUTPUT number * num in Python might look like
print (number * num).
Processing refers to any operation the computer system is performing on data, for example doing a calculation or searching for something. In
OUTPUT number * num, the program is actually performing a calculation within the output, so it is possible to see statements which combine one or more of these.
A flowchart is a diagram that shows an overview of an algorithm. Flowcharts use a variety of standard symbols to represent different elements, and arrows to show the flow or direction. These symbols are used to construct the flowchart and show the step-by-step solution to the problem.
Common flow diagram symbols