14 Programming and Data Structures
This can be represented as follows.
Algorithm
Input a and b.
Is a>b.
Pseudocode
get numbers a & b
Compare a & b
If yes a is larger than b.
If no b is larger than a.
Print the larger number.
larger number is max
if a is large max=a
if b is large max=b
Few skilled programmers prefer to write pseudocode for drawing the flowchart. This is because
using pseudocode is analogous to writing the final code in the programming language. Few
programmers prefer to write the steps in algorithm. Few programmers favour flowchart to represent
the logical flow because with visualization things are clear for writing program statements. For
beginners a flowchart is a straightforward tool for writing a program.
Example (b): The example (b) illustrates how the pseudocode is used to draw a flowchart.
1) Accept number
2) Calculate square of the number
3) Display number
All the steps of the program are written down in steps. Some programs follow pseudocode to draw
flowcharts. Using pseudocode, final program can be written. Majority of programs have common
tasks such as input, processing and output. These are fundamental tasks of any program.
Using pseudocode a flowchart can be drawn as per the following steps.
For the statement, that is, 'Accept number' the flowchart symbol is as per Fig. 1.16.
Fig. 1.16 Input symbol
The* statements including arithmetic operations are examples of processing statements. The
representation of second statement 'Calculate square of the number' can be represented as in
Fig. 1.17.
Calculate square
of the number
Fig. 1.17 Processing symbol
The output statement, that is, 'Display number' can be represented as per Fig. 1.18.
Fig. 1.18 Output symbol