# Pseudo-code and flowchart

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

Every programming language, including pseudo-language, is composed of variables and instructions. Variables store information and describe how to access to computer memory. The instructions allow to modify the state of these variables.
An algorithm is composed of a sequence of instructions which, starting from a description in memory of an unresolved problem, give the modifications of the memory making it possible to arrive at a description in memory of the problem solved.

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.

The algorithm is written in the following way: the header (name of the algorithm), the variables (inputs and outputs with the type), the body (the sequence of instruction starting with a Beginning and an 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 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?

## Flowchart

The role of a flow diagram (or flowchart) is to represent in a more functional way an algorithm. The flowchart represents the body of the algorithm using a graph whose vertices can be of different types, as well as the links. For information, a logic diagram belongs to the category « flow diagram ». 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.

## Correspondences

#### Conditional test: #### Transfer of information: #### Sub-program call:  #### Linear sequence: #### If…else : #### While (the fort contains a downstream and loop processing) : #### Do… while : Etc : Publicités