Introduction To Flowchart
Introduction To Flowchart
Flowcharting
Today’s Topics
• Flowchart Symbols
• Structures
•Sequence
•Selection
•Repetition
Flowchart:
Represents an algorithm
in graphical symbols
Flowchart Symbols
Yes
No
Stop
Connectors on the same page
Start
1 2
2
Connectors on a different page
Page 1 Page 2
Start
2
1
Stop
Yes 1
No
2
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”
process 1
process 2
…
…
process n
Sequence
An Example Using Sequence
Problem: Write a set of instructions that describe how to make a pot of tea.
Pseudocode Flowchart
BEGIN
fill a kettle with water
boil the water in the kettle
put the tea leaves in the pot
pour boiling water in the pot
END
Selection is used in a computer program or
algorithm
to determine which particular step or set of steps
is to be executed
Binary Selection Binary Selection
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
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
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 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
Example:
Start
Read
Length,
Input:
Width Length <- 5
Width <- 3
Area: 15
Print
Area, Perimeter: 16
Perimeter
Stop
Example:
What is the output of the following flowchart when the input Num= 10
Start
Enter a Number >> 10
Category A
Input:
Read Num
Num <- 10
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
Start
Enter a Number >> 0
Category B
Read Num Input: Category A
Num <- 0
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 [[[ 4
0710]
9 ]]] 0497 +++ 4312
Num <- 4 Count
Count [[[ 3
Count 420
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
T. O. L
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.