WEEK 3
Definition of flowchart
Description of flowchart symbols
Solving simple programming table with flowcharts
The flowchart
A flowchart is a pictorial representation of an Algorithm or of the plan of solution
of a problem. It indicates the process of solution, the relevant operations and
computations, point of decision and other information that are part of the solution.
Flowcharts are of particular importance for documenting a program. Special
geometrical symbols are used to construct flowcharts. Each symbol represents an
activity. The activity could be input/out of data, computation/processing of data,
taking a decision, terminating the solution, etc. The symbols are joined by arrows
to obtain a complete flowchart.
Flowchart is a representation of the algorithm using standard symbols. Each
symbols has a new function.
The Algorithm steps determine which symbol to use to represent it in the flow each
step is linked to another step by using the directional arrows.
Example 2
Draw a flowchart to find the average of four numbers stored in variables A,B,C,D.
when the value of A is zero, no averaging is to be done.
Example 3
Write an algorithm and draw a flowchart that will read the two sides of a rectangle
and calculate its area.
Solution
Pseudo code
• Input the Width (w) and Length(L) of a rectangle
• Calculate the area (A) by multiplying L with W
• Print A.
Algorithm
Step 1: Input W, L
Step 2: A← L * W
Step 3: Print A.
Example 4
Write an algorithm and draw a flowchart that will calculate the roots of a quadratic
equation.
ax2+ bx + c = 0
Hint: d = SQrt(b2– 4ac), and the roots are:
X1 = (-b + d)/2a and X2 = (b – d)/ 2a
Solution
Pseudo code
• Input the coefficients (a, b, c) of the quadratic equation
• Calculated
• Calculate X1
• Calculate X2
• Print X1 and X2
Step 1: Input a, b, c
Step 2: d ← Sqrt (b * b – 4 * a * c)
Step 3: X1 ← ( - b + d)/ (2 * a)
Step 4: X2 ← (- b – d)/ (2 * a)
Step 5: Print X1, X2
Start
Input
a, b, c
d ← Sqrt + (b * b – 4*a*c
X1 ← (-b + d)/ (2*a)
X2 ← (-b – d) / (2* a)
Print
X1, X2
Stop
Flowchart
Uses of flowcharts
1 It gives us an opportunity to see the entire system as a whole.
2 It makes us to examine all possible logical outcomes in any process.
3 It provides a tool for communicating i.e a flowchart helps to explain the system
to others.
4 To provide insight into alternative solutions.
5 It allows us to see what will happen if we change the values of the variable in the
system.
ADVANTAGES OF USING FLOWCHART
1. Communication flowcharts are visual aids for communicating the logic of a
system to all concerned.
2. Documentation: flowcharts are a means of documentation because:
3 The analyst/ programmers may leave the arrangement or they may forget the
logic of the program.
4 Changes to the procedure are more easily catered for (modification).
5 Flowchart can be understood by new staff coming to the company
6 Analysis: flowcharts help to clarify the logic of a system i.e the overall picture of
the organization can be seen.
7 Consistency: A flowchart is a consistent system of recording. It brightens the
relationships between different parts of a system.
DISADVANTAGES OF USING FLOWCHART
1. Complex logic: - Where the logic of a problem is complex, the flowchart
quickly becomes clustered and lacks clarity.
2. Alterations: - If alterations are required the flowchart may require redrawing
completely.
3. Reproduction: - As the flowchart symbols cannot be typed, reproduction of
flowchart is often a problem.
Types of flowchart
System flowchart: shows the control of a physical or result level
Program flowchart: shows the control in a program within the system
Input/output flowchart or data flowchart: its normally shows in a control
within a system
Documentation flowchart: it normally shows the document flow over a
system