<< Chapter < Page | Chapter >> Page > |
Also according to Wikipedia ,
"Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm. It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading. Pseudocode typically omits details that are not essential for human understanding of the algorithm...
The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is anefficient and environment-independent description of the key principles of an algorithm."
We can describe the sequence structure using the pseudocode shown in Image 1 .
Thus, the general requirement for the sequence structure is that one or more actions may be performed in sequence after entry and before exit.
There may not be any branches or loops between the entry and the exit.
All actions must be taken in sequence.
However, it is important to note that one or more of the action elements may themselves be sequence, selection, or loop structures.
If each of the structures that make up the sequence has only one entry point and one exit point, each such structure can be viewed as a single action elementin a sequence of actions.
The sequence structure is the simplest of the three, and there's not much more that I can say about it.
The selection or decision structure can be described as shown in the pseudocode in Image 2 .
Once again, there is only one entry point and one exit point.
The first thing that happens following entry is that some condition is tested for true or false .
The concept of something being true or false is commonly referred to as a boolean condition in computer programming (named after George Boole) .
If the condition is true, one or more actions are taken in sequence and control exits the structure.
If the condition is false, none , one or more different actions are taken in sequence and control exits the structure. (Note the inclusion of the word none here.)
Once again, each of the action elements in the sequence may be another sequence, selection, or loop structure.
Eventually all of the actions for a chosen branch will be completed in sequence and control will exit the structure.
It is often the case that no action is required when the test returns false. In that case, control simply exits the structure without performing any actions.
The loop or iteration structure can be described as shown in the pseudocode in Image 3 .
As before, there is only one entry point and one exit point. Note that in this case, the exit point is not at the end of the pseudocode. Instead,it follows the test.
Notification Switch
Would you like to follow the 'Teaching beginners to code' conversation and receive update notifications?