Professional Documents
Culture Documents
FLOWCHARTING
1
WHAT IS A FLOWCHART?
START
Display message
“How many
hours did you
work?”
END
2
BASIC FLOWCHART START Terminal
OR ENDING POINT
Multiply Hours
by PayRate.
START Store result in
GrossPay.
Display
GrossPay
END Terminal
END
3
BASIC FLOWCHART START
• INDICATE AN INPUT OR
Multiply Hours
OUTPUT OPERATION by PayRate.
Store result in
GrossPay.
Display message
“How many Display
GrossPay
Read Hours
hours did you
END
4
work?”
BASIC FLOWCHART START
COMPUTATION OR VARIABLE
Multiply Hours
ASSIGNMENT Process
by PayRate.
Store result in
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.
YES
• IN THIS FLOWCHART SEGMENT, X IS
x < y? Display x
NEVER CHANGED. ONCE THE LOOP
STARTS, IT WILL NEVER END.
• QUESTION: HOW CAN THIS
FLOWCHART BE MODIFIED SO
11
IT IS NO LONGER AN INFINITE
LOOP?
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
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