Flowchart
Flowchart
The Flowchart
A graphical representation of the sequence of operations
in an information system or program.
Information system flowcharts show how data flows from
source documents through the computer to final
distribution to users.
Program flowcharts show the sequence of instructions
in a single program.
Different symbols are used to draw each type of
flowchart.
The Flowchart
A Flowchart
shows logic of an algorithm
emphasizes individual steps and their
interconnections
e.g. control flow from one action to the next
Flow Charts
A flow chart can be used to:
OVAL
Flow Chart Symbols
Denotes a process to be carried out.
Parallelogram
Flow Chart Symbols
Denotes the decision or a branch to be made.
Y N
is
A>B
Print Print
A B
Flow Chart Symbols
Denote the direction of the logic flow in the
program.
Flow lines
Flow Chart Symbols
Display
Information display by printers or plotters.
Flow Chart Symbols
Input
M1,M2,M3,M4
GRADE=(M1+M2+M3+M4)/4
N Y
IS
GRADE>50
PRINT PRINT
“FAIL” “PASS”
STOP
Example 2
Draw a flowchart to convert the length in
feet to centimeter.
Example 2
START
Input
Lft
Lcm = Lft x 30
Print
Lcm
STOP
Example 3
Draw a flowchart that will read the two sides
of a rectangle and calculate its area.
Example 3
START
Input
W, L
A=LxW
Print
A
STOP
Example 4
Draw a flowchart that will calculate the roots
of a quadratic equation
ax 2 bx c 0
Hint: d = sqrt (b2 – 4ac), and the roots are:
x1 = (–b + d)/2a and x2 = – (b + d)/2a
Example 4
START
Input
a, b, c
d = sqrt(b x b – 4 x a x c)
x1 = (–b + d) / (2 x a)
X2 = – (b + d) / (2 x a)
Print
x1 ,x2
STOP
Relational Operators
Relational Operators
Operator Description
> Greater than
< Less than
= Equal to
Greater than or equal to
Less than or equal to
Not equal to
Example 5
Write an algorithm that reads two values, determines the
largest value and prints the largest value with an
identifying message.
ALGORITHM
Step 1: Input VALUE1, VALUE2
Step 2: if (VALUE1 > VALUE2) then
MAX VALUE1
else
MAX VALUE2
endif
Step 3: Print “The largest value is”, MAX
Example 5
START
Input
VALUE1,VALUE2
Y is N
VALUE1>VALUE2
Print
“The largest value is”,
MAX
STOP
Assignment 1
Draw a flowchart that reads three
numbers and prints the value of the largest
number.
Algorithm
Step 1: Input N1, N2, N3
Step 2: if (N1>N2) then
if (N1>N3) then
MAX N1 [N1>N2, N1>N3]
else
MAX N3 [N3>N1>N2]
endif
else
if (N2>N3) then
MAX N2 [N2>N1, N2>N3]
else
MAX N3 [N3>N2>N1]
endif
endif
Step 3: Print “The largest number is”, MAX
Example 6
Flowchart: Draw the flowchart of the
above Algorithm.
Example 7
Write and algorithm and draw a flowchart
to
a) read an employee name (NAME),
overtime hours worked (OVERTIME),
hours absent (ABSENT) and
b) determine the bonus payment
(PAYMENT).
Example 7
Bonus Schedule
OVERTIME – (2/3)*ABSENT Bonus Paid