Flow Charting Lecture
Flow Charting Lecture
FLOWCHARTING
25.1 INTRODUCTION
The flowchart is a means of visually presenting the flow of data through an information
processing systems, the operations performed within the system and the sequence in which
they are performed. In this lesson, we shall concern ourselves with the program flowchart,
which describes what operations (and in what sequence) are required to solve a given
problem. The program flowchart can be likened to the blueprint of a building. As we know a
designer draws a blueprint before starting construction on a building. Similarly, a
programmer prefers to draw a flowchart prior to writing a computer program. As in the case
of the drawing of a blueprint, the flowchart is drawn according to defined rules and using
standard flowchart symbols prescribed by the American National Standard Institute, Inc.
25.2 OBJECTIVES
At the end of this lesson, you will be able to understand:
the meaning of flowchart
the basic parts of the flowchart such as flowchart symbols and the flow lines
connecting these symbols.
the advantages and limitations of flowchart
1
25.4 GUIDELINES FOR DRAWING A FLOWCHART
Flowcharts are usually drawn using some standard symbols; however, some special symbols
can also be developed when required. Some standard symbols, which are frequently required
for flowcharting many computer programs are shown in Fig. 25.1
Start or end of the program
Magnetic Tape
Magnetic Disk
Off-page connector
Flow line
Annotation
Display
2
Fig. 25.1 Flowchart Symbols
No =0
(f) Only one flow line is used in conjunction with terminal symbol.
(g) Write within standard symbols briefly. As necessary, you can use the annotation
symbol to describe data or computational steps more clearly.
(h) If the flowchart becomes complex, it is better to use connector symbols to reduce
the number of flow lines. Avoid the intersection of flow lines if you want to make
it more effective and better way of communication.
(a) Ensure that the flowchart has a logical start and finish.
3
(b) It is useful to test the validity of the flowchart by passing through it with a simple
test data.
4
IN-TEXT QUESTIONS 1
5
25.7 FEW EXAMPLES ON FLOWCHARTING
Now we shall present few examples on flowcharting for proper understanding of this
technique. This will help in student in program development process at a later stage.
Example 1
Draw a flowchart to find the sum of first 50 natural numbers.
Answer: The required flowchart is given in Fig. 25.2.
START
SUM = 0
N=0
N=N+1
SUM = SUM + N
NO
IS N=50?
YES
PRINT SUM
END
6
Fig. 25.2 Sum of first 50 natural numbers
Fig 2.2 Flowchart for computing the sum of first 50 natural numbers.
Example 2
Draw a flowchart to find the largest of three numbers A,B, and C.
Answer: The required flowchart is shown in Fig 25.3
START
READ A, B, C
NO NO
PRINT C PRINT C PRINT A
PRINT B
END
7
Fig 25.3 Flowchart for finding out the largest of three numbers
Example 3
Draw a flowchart for computing factorial N (N!)
Where N! = 1 2 3 …… N .
The required flowchart has been shown in fig 25.4
Answer:
START
READ N
M=1
F=1
F=F*M
NO
IS M=N?
M=M+1
YES
PRINT F
END
8
Example 4
A company’s salesmen are selling toothpaste and tooth powder. The company having 50
salesmen gives 10% commission on the sale of toothpaste and 20% commission on tooth
powder.
Draw a flowchart to compute and print the total sale and the total commission for each
salesman.
Note:
S = Salesman number
P1 = Amount of sales of paste
P2 = Amount of sales of powder
K = Counter for the number of salesman
9
Example 5
Modify the flowchart in Example 4 to print the following heading.
Salesman No Total Sale Total commission
Under these heading, write the values of these variables for the 50 salesmen. At the end, the
totals of the entire sale and the entire commission should also be printed out.
Note:
TS = Total sales
TC = Total commission
Fig: 25.6 Flowchart for writing proper heading and its contents
10
IN-TEXT QUESTION 2
1. What are name and the use of the following symbols?
(a) (b) (c) (d) (e)
2. Define Flowcharting.
11
IN-TEXT QUESTIONS 2
1. Symbol Name Use
(a) input/output To represent input of data for processing
or output of processed information.
(b) Terminal To indicate start or end of a program
12