0% found this document useful (0 votes)
60 views29 pages

Introduction To Flowcharting

1) A flowchart is a diagram that depicts the flow of a program and uses basic symbols like rectangles, diamonds, and arrows. 2) There are four main types of flowchart structures: sequence, decision, repetition, and case. Sequence shows a series of steps. Decision includes if/else logic. Repetition uses loops. Case uses different logic based on conditions. 3) Flowcharts help visualize the logic of a program through basic symbols and structures like inputs, processes, and outputs to represent things like variables, calculations, and program flow.

Uploaded by

Josh Dumalag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views29 pages

Introduction To Flowcharting

1) A flowchart is a diagram that depicts the flow of a program and uses basic symbols like rectangles, diamonds, and arrows. 2) There are four main types of flowchart structures: sequence, decision, repetition, and case. Sequence shows a series of steps. Decision includes if/else logic. Repetition uses loops. Case uses different logic based on conditions. 3) Flowcharts help visualize the logic of a program through basic symbols and structures like inputs, processes, and outputs to represent things like variables, calculations, and program flow.

Uploaded by

Josh Dumalag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

INTRODUCTION TO

FLOWCHARTING

1
WHAT IS A START

FLOWCHART? Display message


“How many
hours did you
work?”

• A FLOWCHART IS A Read Hours

DIAGRAM THAT Display message


“How much do
DEPICTS THE “ FLOW” you get paid per
hour?”
OF A PROGRAM.
• THE FIGURE SHOWN Read PayRate

HERE IS A FLOWCHART Multiply Hours


by PayRate.
FOR THE PAY- Store result in
GrossPay.
CALCULATING
PROGRAM SHOWN IN Display
GrossPay
PROGRAM 1-1. 2
END
BASIC FLOWCHART START Terminal

SYMBOLS Display message


“How many
hours did you
work?”

• TERMINALS Read Hours

• REPRESENTED BY Display message


“How much do
you get paid per
ROUNDED hour?”

RECTANGLES Read PayRate

• INDICATE A
Multiply Hours
STARTING OR by PayRate.
START Store result in
GrossPay.
ENDING POINT
Display
GrossPay

END Terminal
END
3
BASIC FLOWCHART START

SYMBOLS Display message


“How many
hours did you
work?”

• INPUT/OUTPUT Read Hours

OPERATIONS Display message


“How much do Input/Output
you get paid per
Operation
• REPRESENTED BY hour?”

PARALLELOGRAMS Read PayRate

• INDICATE AN INPUT Multiply Hours


by PayRate.
OR OUTPUT Store result in
GrossPay.
OPERATION
Display message
“How many Display

Read Hours GrossPay


hours did you
4
work?” END
BASIC FLOWCHART START

SYMBOLS Display message


“How many
hours did you
work?”

• PROCESSES Read Hours

• REPRESENTED BY Display message


“How much do
you get paid per
RECTANGLES hour?”

• INDICATES A PROCESS Read PayRate

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

• A SERIES OF ACTIONS ARE


PERFORMED IN SEQUENCE
• THE PAY-CALCULATING
EXAMPLE WAS A SEQUENCE
FLOWCHART.

7
DECISION STRUCTURE

• THE FLOWCHART SEGMENT BELOW SHOWS HOW A DECISION


STRUCTURE IS EXPRESSED IN C++ AS AN IF/ELSE STATEMENT.

Flowchart C++ Code

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

• THE FLOWCHART SEGMENT BELOW SHOWS A DECISION STRUCTURE WITH


ONLY ONE ACTION TO PERFORM. IT IS EXPRESSED AS AN IF STATEMENT IN C+
+ CODE.

Flowchart C++ Code

NO YES if (x < y)
x < y? a = x * 2;

Calculate a
as x times 2.

9
REPETITION STRUCTURE

• THE FLOWCHART SEGMENT BELOW SHOWS A REPETITION


STRUCTURE EXPRESSED IN C++ AS A WHILE LOOP.

Flowchart C++ Code

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

• ANSWER: BY ADDING AN ACTION WITHIN THE


REPETITION THAT CHANGES THE VALUE OF X.

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

bonus = 100 bonus = 200 bonus = 400 bonus = 800

13
CONNECTORS

•The “A” connector


indicates that the second START A

flowchart segment begins


where the first segment
ends.

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

• WHAT DO EACH OF THE FOLLOWING SYMBOLS REPRESENT?

17
(Answer on next slide)
ANSWER

• WHAT DO EACH OF THE FOLLOWING SYMBOLS REPRESENT?

Decision
Terminal

Input/Output
Operation Connector

Process Module
18
REVIEW

• NAME THE FOUR FLOWCHART STRUCTURES.

19
(Answer on next slide)
ANSWER

• SEQUENCE
• DECISION
• REPETITION
• CASE

20
Review

• WHAT TYPE OF STRUCTURE IS THIS?

21
(Answer on next slide)
ANSWER

• REPETITION

22
Review

• WHAT TYPE OF STRUCTURE IS THIS?

23
(Answer on next slide)
ANSWER

• SEQUENCE

24
Review

• WHAT TYPE OF STRUCTURE IS THIS?

25
(Answer on next slide)
ANSWER

• CASE

26
Review

• WHAT TYPE OF STRUCTURE IS THIS?

27
(Answer on next slide)
ANSWER

• DECISION

28
29

You might also like