BUILDING BLOCKS OF ALGORITHMS

(iii) The last of the three basic actions, is to deliver/write values of some variables
say i, j, etc. to the monitor or to an external secondary storage by a statement of
the form write (i, j ,….);

The values in the locations loc(i), loc(j),…, corresponding to the variables i, j …, in
the write statement are copied to the monitor or a secondary storage. Generally,
values are written to the monitor by default. In case, the values are to be written to a secondary storage, then identity of the secondary storage is also specified in the write statement. Further, if the argument in a write statement is some sequence of
characters enclosed within quotes then the sequence of characters as such, but without quotes, is given as output. For example, corresponding to the write statement.

Write (‘This equation has no real roots’ ) the algorithm gives the following output:
This equation has no real roots.

In addition to the types of instructions corresponding to the above mentioned actions, there are other non-executable instructions which include the ones that are used to define the structure of the data to be used in an algorithm. These issues shall be discussed latter.

2. Control Mechanisms and Control Structures
In order to understand and to express an algorithm for solving a problem, it is not
enough to know just the basic actions viz., assignments, reads and writes. In addition, we must know and understand the control mechanisms. These are the mechanisms by which the human beings and the executing system become aware of the next instruction to be executed after finishing the one currently in execution. The sequence of execution of instructions need not be the same as the sequence in which the instructions occur in program text. First, we consider three basic control mechanisms or structuring rules, before considering more complicated ones.

(i) Direct Sequencing: When the sequence of execution of instructions is to be
the same as the sequence in which the instruction are written in program text,
the control mechanism is called direct sequencing. Control structure, (i.e.,
the notation for the control mechanism), for direct sequencing is obtained by
writing of the instructions,

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!