Introduction To Flowcharting
Introduction To Flowcharting
FLOWCHARTING
1
WHAT IS A START
• INDICATE A
Multiply Hours
STARTING OR by PayRate.
START Store result in
GrossPay.
ENDING POINT
Display
GrossPay
END Terminal
END
3
BASIC FLOWCHART START
SUCH AS A
Multiply Hours
MATHEMATICAL Process
by PayRate.
Store result in
GrossPay.
COMPUTATION OR
Multiply Hours
VARIABLE ASSIGNMENT Display
by PayRate. GrossPay
Store result in 5
END
GrossPay.
FOUR FLOWCHART STRUCTURES
• SEQUENCE
• DECISION
• REPETITION
• CASE
6
SEQUENCE STRUCTURE
7
DECISION STRUCTURE
NO YES if (x < y)
x < y? a = x * 2;
else
Calculate a Calculate a a = x + y;
as x plus y. as x times 2.
8
DECISION STRUCTURE
NO YES if (x < y)
x < y? a = x * 2;
Calculate a
as x times 2.
9
REPETITION STRUCTURE
while (x < y)
YES x++;
x < y? Add 1 to x
10
CONTROLLING A REPETITION
STRUCTURE
• THE ACTION PERFORMED BY A REPETITION
STRUCTURE MUST EVENTUALLY CAUSE THE
LOOP TO TERMINATE. OTHERWISE, AN
INFINITE LOOP IS CREATED.
• IN THIS FLOWCHART SEGMENT, X IS NEVER
CHANGED. ONCE THE LOOP STARTS, IT WILL YES
NEVER END. x < y? Display x
• QUESTION: HOW CAN THIS
FLOWCHART BE MODIFIED SO
IT IS NO LONGER AN INFINITE
LOOP?
11
CONTROLLING A REPETITION
STRUCTURE
YES
x < y? Display x Add 1 to x
12
CASE STRUCTURE
If years_employed = 2, If years_employed = 3,
bonus is set to 200 bonus is set to 400
If years_employed = 1, If years_employed is
CASE
bonus is set to 100 years_employed any other value, bonus
is set to 800
1 2 3 Other
13
CONNECTORS
END
A
14
MODULES
START
•The position of the module
symbol indicates the point the Read Input.
module is executed.
•A separate flowchart can be Call calc_pay
function.
constructed for the module.
Display results.
END
15
COMBINING STRUCTURES
• THIS NO YES
x > min?
FLOWCHART
SEGMENT
Display “x is NO YES
SHOWS TWO outside the limits.”
x < max?
DECISION
STRUCTURES
Display “x is Display “x is
COMBINED. outside the limits.” within limits.”
16
REVIEW
17
(Answer on next slide)
ANSWER
Decision
Terminal
Input/Output
Operation Connector
Process Module
18
REVIEW
19
(Answer on next slide)
ANSWER
• SEQUENCE
• DECISION
• REPETITION
• CASE
20
Review
21
(Answer on next slide)
ANSWER
• REPETITION
22
Review
23
(Answer on next slide)
ANSWER
• SEQUENCE
24
Review
25
(Answer on next slide)
ANSWER
• CASE
26
Review
27
(Answer on next slide)
ANSWER
• DECISION
28
29