0% found this document useful (0 votes)
51 views35 pages

Introduction To Flowcharting

This is a decision structure. It contains two decision points (the diamonds) that determine which path is taken based on whether a condition is true or false. next slide) 21 Review • What type of structure is this? (Answer on next slide)

Uploaded by

Faisal Tehseen
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)
51 views35 pages

Introduction To Flowcharting

This is a decision structure. It contains two decision points (the diamonds) that determine which path is taken based on whether a condition is true or false. next slide) 21 Review • What type of structure is this? (Answer on next slide)

Uploaded by

Faisal Tehseen
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/ 35

Introduction to

Flowcharting

1
START

What is a Flowchart? Display message


“How many
hours did you
work?”

• A flowchart is a Read Hours

diagram that depicts Display message


“How much do
the “flow” of a you get paid per
hour?”

program.
Read PayRate
• The figure shown here
is a flowchart for the Multiply Hours
by PayRate.

pay-calculating
Store result in
GrossPay.

program shown in Display

Program 1-1. GrossPay

END
2
Basic Flowchart START Terminal

Symbols Display message


“How many
hours did you
work?”

• Terminals Read Hours

– represented by rounded Display message


“How much do
rectangles you get paid per
hour?”
– indicate a starting or
ending point Read PayRate

Multiply Hours
by PayRate.
START Store result in
GrossPay.

Display
GrossPay

END Terminal
END
3
Basic Flowchart START

Symbols Display message


“How many
hours did you
work?”

• Input/Output Operations Read Hours

– represented by Display message


“How much do
parallelograms you get paid per
Input/Output
Operation
hour?”
– indicate an input or output
operation Read PayRate

Multiply Hours
by PayRate.
Display message Store result in
GrossPay.
“How many
Read Hours
hours did you Display
GrossPay
work?”
END
4
Basic Flowchart START

Symbols Display message


“How many
hours did you
work?”

• Processes Read Hours

– represented by rectangles Display message


“How much do
– indicates a process such as you get paid per
hour?”
a mathematical
computation or variable Read PayRate

assignment
Multiply Hours
by PayRate.
Process Store result in
Multiply Hours GrossPay.
by PayRate.
Store result in Display
GrossPay
GrossPay.
END
5
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 never end.
• QUESTION: How can this
YES
flowchart be modified so x < y? Display x
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 flowchart segment
shows two decision NO YES
structures combined. x > min?

Display “x is NO YES
outside the limits.”
x < max?

Display “x is Display “x is
outside the limits.” within limits.”

16
Review
• What do each of the following symbols
represent?

(Answer on next slide)


17
Answer
• What do each of the following symbols
represent?
Decision
Terminal

Input/Output
Operation Connector

Process Module

18
Review
• Name the four flowchart structures.

(Answer on next slide)


19
Answer
• Sequence
• Decision
• Repetition
• Case

20
Review
• What type of structure is this?

(Answer on next slide)


21
Answer
• Repetition

22
Review
• What type of structure is this?

(Answer on next slide)


23
Answer
• Sequence

24
Review
• What type of structure is this?

(Answer on next slide)


25
Answer
• Case

26
Review
• What type of structure is this?

(Answer on next slide)


27
Answer
• Decision

28
29
Examples ???

30
Direction of Numbered NYC
Streets Algorithm
• Problem: Given a street number of a one-
way street in New York City, decide the
direction of the street, either eastbound or
westbound
• Discussion: in New York City even
numbered streets are Eastbound, odd
numbered streets are Westbound

31
Flowchart

32
Simple Summation Process

33
Flowchart Example – Calculate Profit and Loss

34
• Flowchart Example – Medical Service
This is a hospital flowchart example that shows how clinical cases shall be
processed. This flowchart uses decision shapes intensively in representing
alternative flows

35

You might also like