Before writing an algorithm in a programming language, it is first described in a higher level language called pseudo-language. It is composed by 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 to do it 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 sequence of instructions of the type power.
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.
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 Read or Write, existing in most computer languages, when the operation of these languages is known.
Most of the time the body algorithm is based on the following scheme: what we ask to the user, what is calculated, what is restored?
It is not necessary to note Decision and Calculation, these indications are only present to show the role of the vertices in this logigram. Here is a sample of the correspondences between pseudo-language and flowchart.
Transfer of information:
While (the fort contains a downstream and loop processing) :
Do… while :