Flow Charts: What Are They Good For?
Flow Charts: What Are They Good For?
Wait Statement
(Pause)
Sub-Routines within a Program
Making an Effective Flow Chart
• Define the process boundaries with starting and ending points.
• Complete the big picture before filling in the details.
• Clearly define each step in the process. Be accurate and honest.
• Identify time lags and non-value-adding steps.
• Circulate the flowchart to other people involved in the process to get their comments.
• Flowcharts don't work if they're not accurate or if the team is too far removed from the process itself. Team
members should be true participants in the process and feel free to describe what really happens. A thorough
flowchart should provide a clear view of how a process works. With a completed flowchart, you can:
• Identify time lags and non-value-adding steps.
• Identify responsibility for each step.
• Brainstorm for problems in the process.
• Determine major and minor inputs into the process with a cause & effect diagram.
• Choose the most likely trouble spots with the consensus builder.
Flow Chart: Student Assignment
Submission
Sequence
In a computer program or an algorithm,
sequence involves simple steps which are
to be executed one after the other.
The steps are executed in the same order in which they are written.
In a flowchart,
sequence is expressed as:
In pseudocode,
sequence is expressed as:
process 1
process 2
…
…
process n
The detail of how the function works
is put in another flowchart.
Read
n1, n2 , n3
Body of a function is
AVRG (result, n1, n2,n3) the same with
normal flowchart
Stop
End terminal
must be a “Return”
Start
1 2
2
Connectors on a different page
Page 1 Page 2
Start
2
1
Stop
Yes 1
No
2
Example:
Start
Read
Length, Input:
Width Length <- 5
Width <- 3
Area: 15
Print
Area, Perimeter: 16
Perimeter
Stop
Selection is used in a computer program or algorithm
to determine which particular step or set of steps is to
be executed
1. IF condition THEN
process 1
ENDIF
2. IF condition THEN
process 1
ELSE
process 2
ENDIF
Selection
Binary (structure)
Binary Selection Binary Selection
1. IF condition THEN
process 1
ENDIF
2. IF condition THEN
process 1
ELSE
process 2
ENDIF
Repetition
Repetition allows for a portion of an algorithm or computer program
to be done any number of times
dependent on some condition being met.
An occurrence of repetition is usually known as a loop.
Repetition
Repetition In flowcharting
pre-test repetition
In pseudocode, pre-test is expressed as:
repetition is expressed as:
Repetition
Repetition In a flowchart
post-test repetition
In pseudocode, post-test is expressed as:
repetition is expressed as:
REPEAT
process
UNTIL condition is true
Repetition Pre-test (example)
An Example Using Pre-Test Repetition
Problem: Determine a safety procedure for travelling in a carriage on a moving train.
Pre-test Repetition
Flowchart
Pre-test Repetition
Pseudocode
Post-test Repetition
Flowchart
Post-test Repetition
Pseudocode
REPEAT
beat the egg whites
UNTIL fluffy
Comments or description
Start
Yes
No
Stop
Selection
Binary (flowchart structure)
Note: In a flowchart it is most important to indicate
1. which path is to be followed when the condition is true, and
2. which path to follow when the condition is false.
Without these indications the flowchart is open to more than one interpretation.
Note: There are two acceptable ways to represent a decision in all of the structures.
Either method is acceptable. For consistency, the method 1 is used throughout this document.
Binary Selection
Flowchart
Binary Selection
Pseudocode
CASEWHERE signal is
red : stop the vehicle
amber : stop the vehicle
green : proceed through
the intersection
OTHERWISE : proceed with
caution
ENDCASE
Example:
What is the output of the following flowchart when the input Num= 10
Start
Enter a Number >> 10
Input:
Num <- 10 Category A
Read Num
Num = 10
10 > 0 ? => YES
Num>0? No
Print
"Category B"
Yes
Print
Output:
"Category A"
“Category A”
Stop
Example:
What is the output of the following flowchart when the input is Num= 0
Input: Category B
Read Num Num <- 0
Category A
Num = 0
Output:
0 > 0 ? => NO
“Category B”
Num>0? No
Print
"Category B"
Yes
Print
Output:
"Category A"
“Category A”
Stop
Example:
What is the output of the following flowchart when the input is Num= 4
Start Variables
Variables
Variables (in
(in
(inmemory):
memory):
memory):
Num
Num
Num [[[ 444 ]]]
Read Num Input: Result
Result
Result [[[ 0
4710]
9 ]]] 0497 +++ 4312
Num <- 4 Count
Count
Count [[[ 3420
1 ]]] 4312 --- 111
Initialize
Result=0
Count=Num
Print
Result
Stop
Example:
What is the output of the following flowchart when the input is N = 6
10
Page 1 Page 2 5
average
Start
N=6
AVRG ( result,n1, n2,n3)
Read
N Sum = 10 + 5 + 6
result = sum/3
Print
average Output:
Average: 7
Return
Stop
Quiz
1. What is a flowchart?
2. It is used to connect remote flowchart portion on the same page.
One flow line enters and one flow line exits.
3-5. Control Structures of Flowchart.
Assignment
• Demo: Flow Chart: Number Factorial
• Student Flow Chart Project
• Program 1: Loop/Repetition
• User Inputs x number of values
• Exit when user types in 0 (zero)
• Program adds numbers together
• Output Average of User input
• Program 2: Selections
• Create a flowchart that takes 4 marks from the user, calculates and outputs the average and then
tells the user their letter grade based on the following guidelines: A = 80-100, B = 70-79.9, C = 60-69.9, D = 50-
59.9, F < 50.