0% found this document useful (0 votes)
44 views40 pages

LESSON 2 - Flowchart

The document provides an overview of flowcharts, which are pictorial representations of algorithms that depict the flow of steps in a program. It explains the different symbols used in flowcharts, including rounded rectangles for terminals, parallelograms for input/output operations, and rectangles for processes. Additionally, it discusses various flowchart structures such as sequence, decision, and repetition, along with practical examples and applications for programmers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views40 pages

LESSON 2 - Flowchart

The document provides an overview of flowcharts, which are pictorial representations of algorithms that depict the flow of steps in a program. It explains the different symbols used in flowcharts, including rounded rectangles for terminals, parallelograms for input/output operations, and rectangles for processes. Additionally, it discusses various flowchart structures such as sequence, decision, and repetition, along with practical examples and applications for programmers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

PREVIOU

S TOPIC:
Algorithm
Representation
LESSON
3
Flowchart
1. Sequence
2. Decision
Flowchart
 Algorithms
can be pictorially
represented.

A flowchart is:

 a pictorial representation depicting the flow


of steps in a program

 a diagrammatic representation of the


sequence of processing operation
Pseudo code vs
Flowchart
START

gross pay = 0

Start
Display prompt
gross pay = 0 “How many
hours did you
work?”
Input hours
Input pay rate Input hours

gross pay = hours * pay Display prompt

rate “How much do


you get paid per
hour?”
Output gross pay
STOP Input pay rate

gross pay =
hours * pay
rate

Outputy “Your
gross pay is” +
gross pay

STOP
Uses of Flowchart
 Programmers use flowchart for a number
of purposes.

1. To clarify the logic of a problem.


2. To analyze the actions resulting from a set of
conditions.
3. To sort out the procedural steps in the
program.
4. As aids to program construction and coding.
5. As communicating documents –To explain
the program to other programmers and the
system analyst.
START Rounded
Rectangle
Hexagon gross pay = 0

Display prompt

Basic Flowchart “How many


hours did you
work?”
Symbols
Input hours
 Noticethere are
three types of Display prompt
“How much do
Parallelogra
symbols in this you get paid per
hour?” m
flowchart:
 rounded rectangles Input pay rate

 parallelograms gross pay =


 a rectangle Rectangle hours * pay
rate
 Each symbol Output “Your
represents a gross pay is” +
gross pay

different type of Rounded STOP


Rectangle
operation.
START Rounded
Rectangle
gross pay = 0

Display prompt

Basic Flowchart “How many


hours did you
work?”
Symbols
Input hours
 Terminals
Display prompt
 represented by “How much do
you get paid per
rounded rectangles hour?”
 indicate a starting or
ending point Input pay rate

gross pay =
START hours * pay
rate

Output “Your
STOP gross pay is” +
gross pay

Rounded STOP
Rectangle
START

gross pay = 0

Display message

Basic Flowchart “How many


hours did you
work?”
Symbols
Input hours
 Input/Output
Operations
Display message
“How much do
you get paid per Parallelogra
 represented by hour?” m

parallelograms
Input pay rate
 indicate an input or
output operation
gross pay =
hours * pay
rate
Display message
“How many hours Input hours Output “Your
did you work?” gross pay is” +
gross pay

STOP
START

gross pay = 0

Display prompt

Basic Flowchart “How many


hours did you
work?”
Symbols
Input hours
 Processes
Display prompt
 represented by “How much do
you get paid per
rectangles hour?”
 indicates a process
such as a Input pay rate

mathematical
computation or gross pay =
hours * pay
variable assignment Rectangle
rate

Gross pay = Output “Your


hours * pay rate gross pay is” +
gross pay

STOP
START

gross pay = 0
Hexagon

Display prompt

Basic Flowchart “How many


hours did you
work?”
Symbols
Input hours
 Initialization
Display prompt
 represented by “How much do
you get paid per
hexagon hour?”
 Defines variables to
be used in flowchart Input pay rate

gross pay =
hours * pay
rate
gross pay = 0
Display “Your gross
pay is” + gross pay

STOP
START

gross pay = 0

Display prompt

Basic Flowchart “How many


hours did you
work?”
Symbols
Input hours
 Flow lines
Display prompt
 Indicates direction of “How much do
you get paid per
flow hour?”

Input pay rate

Gross pay = gross pay =


hours * pay
hours * pay rate rate

Output “Your
gross pay is” +
gross pay

STOP
START

Stepping gross pay = 0

Through the Display prompt


“How many
hours did you

Flowchart
work?”

Input hours

How many Display prompt


hours did “How much do
you work? you get paid per
hour?”

Input pay rate

gross pay =
hours * pay
rate

Output “Your gross


Variable Contents: pay is” + gross pay

hours: ? STOP
pay rate: ?
gross pay: 0
START

Stepping gross pay = 0

Through the Display prompt


“How many
hours did you

Flowchart
work?”

Input Operation
Input hours
(User types 40)

How many Display prompt


hours did “How much do
you work? you get paid per
hour?”

Input pay rate

gross pay =
hours * pay
rate

Output “Your gross


Variable Contents: pay is” + gross pay

hours: 40 STOP
pay rate: ?
gross pay: 0
START

Stepping gross pay = 0

Through the Display prompt


“How many
hours did you

Flowchart
work?”

Input hours

How much Display prompt


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

Input Operation
Input pay rate
(User types
400)
gross pay =
hours * pay
rate

Variable Contents: Output “Your gross


pay is” + gross pay

hours: 40
STOP
pay rate: 400
gross pay: 0
START

Stepping gross pay = 0

Through the Display prompt


“How many
hours did you

Flowchart
work?”

Input hours

Your gross Display prompt


pay is 16000 “How much do
you get paid per
hour?”

Input pay rate

Process: The gross pay =


product of 40 hours * pay
times 400 is rate
stored in gross
pay
Variable Contents: Output “Your gross
pay is” + gross pay

hours: 40
STOP
pay rate: 400
gross pay: 16000
Flowchart Symbols
Flowchart Symbols
(con’t…)
Flowchart Structures
Sequence
Decision
Repetition
Sequence Structure
a series of actions
are performed in
sequence
 The pay-
calculating
example was a
sequence
flowchart.
Decision Structure
 One of two
false true
possible actions is IF
taken, depending condition

on a condition.

ELSE logic THEN logic


Decision Structure
 In the flowchart
segment below, the false true
question “is x < y?” x < y?
is asked. If the
answer is no, then
process B is Process B Process A
performed. If the
answer is yes, then
process A is
performed.
Decision Structure
 Theflowchart
segment below false true
shows a decision x < y?
structure with only
one action to
Process A
perform. If the
.
answer is yes, then
process A is
performed; otherwise
no process is
performed.
Repetition Structure
A repetition
structure
represents part of condition
true
the program that
repeats. This type
false
of structure is
commonly known
as a loop. while loop - If the condition
still exists, the action is repeated.
This continues until the condition
no longer exists.
Repetition Structure
A repetition
structure
represents part of
the program that false
repeats. This type condition

of structure is
commonly known true
as a loop. repeat until loop - If the condition
does not exist, the action is
repeated. This continues until the
condition already exists.
Repetition Structure
 In the flowchart
segment, the question
“is x < y?” is asked. If
the answer is true, then
Process A is performed. true
The question “is x < y?” x < y? Process A
is asked again. Process
A is repeated as long as
false
x is less than y. When x
is no longer less than y,
the repetition stops and
the structure is exited.
Repetition Structure
 In the flowchart
segment, the question
“is x == 0?” is asked. If
the answer is false, then
Process A is performed. Process A
The question “is x ==
y?” is asked again.
Process A is repeated as
long as x is not equal to false
0. When x becomes x = = 0?
equal to 0, the repetition
stops and the structure is true
exited.
ACT_1
Flowcharts
(Sequence)
Create flowcharts that:
1. reads in two integers and then outputs
their sum, difference, and product
(DONE)
2. reads in a student’s four exam scores,
as integers, and outputs the student’s
average
3. reads the radius of a circle and outputs
the area & circumference
Create flowcharts that:
4. reads in an integer and outputs if it’s
positive or negative (DONE)
5. reads in an integer and determines if
it’s even or odd (Note that zero is
considered as even)
6. reads in a non-zero integer and outputs
the square root if it is positive or
square if it is negative
Other Flowchart
Structures
Nested if
Case
Go to
Nested if structure
Nested if pseudo code:
It is an IF
statement in
which the true
or false
statement is
itself an IF
statement.
Nested if structure
Nested if flowchart:
Case structure
 It Case pseudo code:
is a structure
where one of
several possible
actions is taken,
depending on
the contents of
a variable.
Nested if structure
Case flowchart:

switch
year

1 2 3 4 else

Process A Process B Process C Process D Process E


Nested if structure
Case flowchart:

switch
If (year == 1) If (year ==2) do If (year ==3) do year If (year ==4) do If is any other value
do process A process B process C process D do process E

1 2 3 4 else

Process A Process B Process C Process D Process E


ACT_2
Flowcharts
(Decision)
Create flowcharts that:
1. reads in the student’s average grade and
determines the letter grade equivalent
letter grade is ‘A’ if average grade is above 89
letter grade is ‘B’ if average grade is above 79
letter grade is ‘C’ if average grade is above 69
letter grade is ‘D’ if average grade is above 59
letter grade is ‘E’ if average grade is above 49
otherwise, the letter grade is ‘F’

Display the student’s average grade and letter grade.


Create flowcharts that:
2. reads in a salesperson’s gross sales and
determines the commission due to him
20 % of the total sales if it is up to Php 10,000
22% of the total sales if it is over Php 10,000 to Php 15,000
24% of the total sales if it is over Php 15,000 to Php 20,000
26% of the total sales if it is over Php 20,000 plus a bonus of
Php 2000.00

Display the total sales (basic pay plus commission).


NEXT:
Flowcharts
-Iteration

You might also like