3 Flow Charts (E-Next - In)
3 Flow Charts (E-Next - In)
Elementary Concepts
INTRODUCTION
Before solving a problem with the help of a computer, it is essential to plan the solution in a step by step
manner. Such a planning is represented symbolically with the help of the so-called flowchart. It is an important
tool of systems analysts and programmers for tracing the information flow and logical sequence in data
processing. Logic is the essence of a flowchart.
A flowchart is the symbolic representation of the step by step solution of a given problem, and it
indicates the flow of the entire process, the sequence of data input, operations, computations, decisions,
results and other relevant information, pertaining to a particular problem. A flowchart helps us in the
complete understanding of the logical structure of a complicated problem and in documenting the method
used. As one studies the subsequence chapter, it would be seen that a flowchart is a very convenient method
of organizing the logical steps and deciding what, when and how to proceed with the various processes.
Flowcharts can be drawn for simple as well as complex operations and are possible even in a non-
computerised environment. Trial and error should be avoided as the computer time is precious. The logic
should be depicted in the flowchart. Computerization of data without a flowchart is like constructing a building
without proper design and detailed drawings. KINDS OF FLOWCHARTS
Flowcharts can be broadly classified into two categories
( 1) System Flowcharts: These are used by Systems Analysts to describe the data flow and operations for
a data processing cycle. A system flowchart defines the broad processing in the organizations, showing the
origin of data, filling structure, processing to be performed, output that is to be generated and necessity of any
off-line operation. This book does not cover this aspect of System flowcharts.
(2) Program Flowcharts : These are normally used by the programmers to describe the sequence of
operations and decisions for a particular problem. A program flowchart plans the program structure and also
serves the purpose of documentation for a program which is to be retained and used at a later data by either
the original programmer or others. The reader is recommended to prepare a detailed program flowchart for
the solution of a given problem which should include the basic steps, expanded to a level, from which
instructions can be directly coded.
The subsequent chapters of this book illustrate program flowcharts for various types of problems. An
attempt has been made to draw these flowcharts so as to be suitable for direct conversion into any computer
language like COBOL, BASIC, FORTRAN, PASCAL, PL/1 etc., just by following the syntax rules of that languages.
SYMBOLS USED IN FLOWCHARTS
The flowchart being a symbolic representation,* standard symbols have been evolved. These symbols
are used to represent the sequence of operations and the flow of data and the documents required for
programming and systems
PRE-DEFINED
TERMINAL POINT (START/STOP) PROCESS
PROCESS
FLOW-LINE
(DIRECTION)
DECISION
DOCUMENT
VISUAL DISPLAY (PRINT-OUT)
No Yes
P=Q
This will first evaluate the condition P = Q. If P is equal to Q then the flow will go along the path
indicated by "YES" But if P is more than Q or less than Q (i.e. not equal to Q) then the flow goes along the path
indicated by "NO".
A rectangle symbol indicates any processing, computation and arithmetic or replacement (assignment)
operations.
A connector symbol ( a small circle) is used to connect the various portions of a flowchart. This is
normally used when the flowchart is split between various pages. A number/alphabetic character may be
written inside the circle. The circles, with same character inside them, represent the same point i.e. these are
to be joined together.
The annotation symbol is used to indicate the comments/remarks on the contents of a procedure in
order to clarify some point of the flowchart.
The document symbol is used to show any input data that is received on paper (like vouchers etc.) or any
report generated as a result of a process. In this book this symbol is used to indicate any result that is printed
out i.e., for all the outputs.
The predefined process symbol is used to show a procedure that has been already defined by another
flowchart. A reference to the appropriate flowchart is written, inside such a symbol. It actually indicates a
number of processing steps whose details is not required at this point.
The arrow symbol is used for flowchart direction and to connect the various flowchart symbols.
The visual display symbol is used to denote any output that is obtained on screen/console. This is
normally used in query programs.
ADVANTAGES OF FLOWCHARTS
The basic concepts associated with flowcharting has been presented in this chapter. Though the
flowcharts have been mostly used to help the programmer develop the program logic and to serve as
documentation for a completed program, but its advantages are many, which may be summarized as follows :
I. It is a convenient method of communication.
II. It indicates very clearly just what is being done, where as a program has logical complexities.
III. It is a key to correct programming.
IV. It is an important tool for planning and designing a new system
V. It clearly indicates the role played at each level.
VI. It saves the inconveniences in future and serves the purpose of documentation for a system.
VII. It provides an overview of the system and also demonstrates the relationship between various steps.
VIII. It facilitates trouble shooting.
IX. It promotes logical accuracy.
X. It makes sure that no logical path is left incomplete without any action being taken.
AN EXAMPLE
Let us illustrate the flowcharting concepts with an example where we want to draw a flowchart for the
following problem:
5. Is Jack broke ?
(a) Yes : Kim wins. Go to step 7
(b) No : Go to step 3.
6. Is Kim broke ?
(a) Yes : Jack wins.. Go to step 7
(b) No : Go to step 3.
7. Stop.
START
GIVE 10 COINS TO
JACK AND KIM
ASK HARY TO
THROW THE DICE
IS THE
OUTCOME
ODD
IS JACK
NO IS KIM NO
BROKE
BROKE
YES YES
JACK WINS
KIM WINS
STOP
Start
READ BN
PRINT OC
STOP
START
READ BN
OC=1-BN
PRINT OC
STOP
Fig.4(b) Alternate Solution
An alternate solution of this problem appear in Fig. 4(b). Here a structured approach has been followed
and the use of decision box is eliminated. The 1 's complement OC is obtained by subtracting the given binary
number BN from 1. If the input value of BN is 1 then OC = 1-1=0 and if the input value of BN is o then OC = 1 - 0
= 1 which is the correct value of 1 's complement.
Example 3. (Celcius to Fahrenheit).
Draw a flowchart to convert the temperature specified in degree Celcius to Fahrenheit. The desired
conversion is based on the formula.
F = (9 * C) / 5 + 32
where C specifies the temperature in degree Celcius and F is its corresponding value in Fahrenheit.
We first read the value of the temperature in degree Celcius. Let the variable C denote this. The reading
operation is specified by the parallelogram shaped input-box in Fig. Use the formula for conversion and the
rectangular box represents this computation The result is stored in the memory location with label F, Which is
finally printed and the processing ends.
F = (9 * C) / 5 + 32
Let us assume that the memory location with label C Contains a value 25. Then F = (9 * C) / 5 + 32 results
in a value 77 which is the corresponding Fahrenheit equivalent of 25 celcius degrees.
Example 4. Draw a flowchart to generate and print first N positive integers 1, 2, 3, , N.
Let us-assume a variable (say A) to denote the positive integer generated at any instant. The initial value of this
variable should be assigned 1. Note that any positive integer can be obtained by adding 1 to its predecessor.
Hence, it is a repeating process. We will always and 1 to the present value of A and the next integer will be A +
1. Which is the successor of the previous value of A. As this next integer is to be used again in order to
calculate its successor, we assign A + 1 to A. The entire process will form a loop (refer section 3) which will
terminate as soon as the value of A reaches N, The complete formulation of the problem is as below and Fig. 6
is its flowchart representation.
YES
Stop
2. Input the value of N, i.e., the number of Integers to be generated (parallelogram-shaped box).
3. Assign 1 to variable A (rectangular-box).
4. Print A (Print-box).
5. Is the value of A equal to the value of N ? (Decision-box)
STOP
START
NUM=0
NUM=NUM+1
PRINT NUM
I=I+2 I=11
NO
YES
FIG 8
STOP
Example 8. (Factorial of a number) The factorial of a number is the product of first N positive integers. It is
denoted by N !
START
READ N
FACT=1
I=2
FACT=FACT*I
NO
I=I+2 I=N
YES
PRINT FACT
STOP
AREA = √s(s-a)(s-b)(s-c)
wheres s = (a + b + c)/2
for the calculation of the area
START
READ A,B,C
S=(A+B+C)/2
AREA=√S(S-A)(S-B)(S-C)
PRINT AREA
STOP