8 Programming and Data Structures
1.6 FLOWCHARTS
A flowchart is a visual representation of the sequence of steps for solving a problem. It enlightens
what comes first, second, third, and so on. A completed flowchart enables you to organize your
problem into a plan of actions. Even for designing a product a designer many times has to draw a
flowchart. It is a working map of the final product. This is an easy way to solve the complex designing
problems. The reader follows the process quickly from the flowchart instead of going through the
text.
A flowchart is an alternative technique for solving a problem. Instead of descriptive steps, we use
pictorial representation for every step. It shows a sequence of operations. A flowchart is a set of
symbols, which indicates various operations in the program. For every process, there is a
corresponding symbol in the flowchart. Once an algorithm is written, its pictorial representation
can be done using flowchart symbols. In other words, a pictorial representation of a textual algorithm
is done using a flowchart.
We give below some commonly used symbols in flowcharts.
Start and end: The start and end symbols indicate both the beginning and the end of the flowchart.
This symbol looks like a flat oval or is egg shaped. Fig. 1.5 shows the symbol of Start/stop.
Only one flow line is combined with this kind of symbol. We write START, STOP or END in the
symbols of this kind. Usually this symbol is used twice in a flowchart, that is, at the beginning and
at the end.
^ Start ^
( St°p )
Fig. 1.5 Start/stop symbol
Decision or test symbol: The decision symbol is diamond shaped. This symbol is used to take one
of the decisions. Depending on the condition the decision block selects one of the alternatives. While
solving a problem, one can take a single, two or multiple alternatives depending upon the situation.
All these alternatives are illustrated in this section. A decision symbol with a single alternative is
shown in Fig. 1.5. In case the condition is satisfied /TRUE a set of statement(s) will be executed
otherwise for false the control transfers to exit.
Single alternative decision: Here more than one flow line can be used depending upon the condition.
It is usually in the form of a 'yes' or 'no' question, with branching flow lines depending upon the
answer. With a single alternative, the flow diagram will be as per Fig. 1.6.
Program Development Styles and Basics of C 9
Entry
False
Exit
Fig. 1.6 Single alternative decision
Two alternative decisions: In Fig. 1.7 two alternative paths have been shown. On satisfying the
condition statement(s) pertaining to 1 action will be executed, otherwise the other statement(s) for
action 2 will be executed.
Entry
Exit
Fig. 1.7 Two alternative decisions
Multiple alternative decisions: In Fig. 1.8 multiple decision blocks are shown. Every decision block
has two branches. In case the condition is satisfied, execution of statements of appropriate blocks
take place, otherwise next condition will be verified. If condition 1 is satisfied then block 1 statements
are executed. In the same way, other decision blocks are executed.
10 Programming and Data Structures
Entry
Exit
Fig. 1.8 Multiple alternative decisions
Connector symbol: A connector symbol has to be shown in the form of a circle. It is used to establish
the connection, whenever it is impossible to directly join two parts in a flowchart. Quite often, two
parts of the flowcharts may be on two separate pages. In such a case, connector can be used for
joining the two parts. Only one flow line is shown with this symbol. Only connector names are
written inside the symbol, that is, alphabets or numbers. Fig. 1.9 shows the connector symbol.
Connector for connecting Connector that comes from the
to the next block previous block
Fig. 1.9 Connector symbol
Program Development Styles and Basics of C 11
Process symbol: The symbol of process block should be shown by a rectangle. It is usually used for
data handling, and values are assigned to the variables in this symbol. Fig. 1.10 shows the process
symbol. The operations mentioned within the rectangular block will be executed when this kind of
block is entered in the flowchart. Sometimes an arrow can be used to assign the value of a variable
to another. The value indicated at its head is replaced by the tail values. There are two flow lines
connected with the process symbol. One line is incoming and the other line goes out.
Fig. 1.10 Process symbol
Loop symbol: This symbol looks like a hexagon. This symbol is used for implementation of
for loops only. Four flow lines are associated with this symbol. Two lines are used to indicate the
sequence of the program and remaining two are used to show the looping area, that is, from the
beginning to the end.
For the sake of understanding, Fig. 1.11 illustrates the working of for loop. The variable J is initialized
to 0 and it is to be incremented by a step of 2 until it reaches the final value 10. For every increased
value of J, body of the loop is executed. This process will be continued until the value of J reaches 10.
Here the next block is shown for the repetitive operation.
Entry
Fig- 1- 11 For loop
12 Programming and Data Structures
Input/output symbol: Input/output symbol looks like a parallelogram, as shown in Fig. 1.12. The
input/output symbol is used to input and output the data. When the data is provided to the program
for processing, then this symbol is used. There are two flow lines connected with the input/output
symbol. One line comes to this symbol and the other line goes from this symbol.
As per Fig. 1.12 compiler reads the values of X, Y and in the second figure the result is displayed on
the monitor or the printer.
Fig. 1.13 Delay symbol
Delay symbol: Symbol of delay is just like 'AND' gate. It is used for adding delay to the process. It
is associated with two lines. One is incoming and the other is outgoing, as shown in Fig. 1.13.
Manual input symbol: This is used for assigning the variable values through the keyboard, wheteas
in data symbol the values are assigned directly without manual intervention. Fig. 1.14 represents
the symbol of manual input.
Fig- 1 .12 Input/output symbol
Fig. 1.14 Manual input symbol
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.133.180