Contents
TogglePseudo-language and flowchart
Before writing a algorithm in a programming language, it is first described in a higher level language called the pseudo-language. It is a limited set of instructions to describe how the algorithm works in such a way that anyone can understand how it works. The pseudo-language is usually written in English, but nothing prevents it from being written in another language.
Writing an algorithm
For example, if we want to calculate x ^ 2 ^ k. x and k are two variables, the problem is described as soon as we know the two values. The problem is solved by a series of instructions of the power type
Interactions with the user are also described by the algorithm through input and output instructions. Here the inputs are the values of x and k, the output is the power value.
The algorithm is written as follows: the header (name of the algorithm), the variables (inputs and outputs with the type), the body (the sequence of instructions starting with a Beginning and ending with a " closing of the process ”noted End).
It is important to add comments preceded by "//" in order to clarify the intentions of the algorithm. It is possible to use explicit function names such as Enter or Write, existing in most computer languages, when the operation of the latter is known.
Most of the time the body of the algorithm is based on the following diagram: what we ask the user, what we calculate, what we restore
Writing a flowchart
It is not necessary to note Decision and Calculation, these indications are only present to show the role of the vertices in this flowchart. Here is a sample of the correspondences between pseudo-language and flowchart.
Pseudo-language and flowchart
Conditional test:
Information transfer:
Subprogram call:
Linear sequence:
If ... else:
While Loop (the for contains downstream and in-loop processing):
Do ... while loop:
More complete list in English: