Module 2 - Flowcharting and Pseudocode
Module 2 - Flowcharting and Pseudocode
Module 2 - Flowcharting and Pseudocode
SCIENCES
Prayer Before Study
by St. Thomas Aquinas
Lord, true source of light and wisdom, give me a
keen sense of understanding, a retentive memory
and the capacity to grasp things correctly. Grant
me the grace to be accurate in my expositions
and the skill to express myself with thoroughness
and clarity. Be with me at the start of my work,
guide its progress and bring it to completion.
Grant this through Christ our Lord, Amen.
Module 2:
Flowcharting and
Pseudocode
ICS2602
Computer Programming I
(Imperative)
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Objectives
Objectives
After studying Module 2, students should
be able to:
What
What is
is algorithm?
algorithm?
• Set of instructions to perform a specific task
• Well-defined step-by-step solution
• Flowchart
• Graphical representation of an algorithm
• Pseudocode
• Method of describing algorithms using
combination of natural language and
programming language
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Flowcharting
Flowcharting Symbols
Symbols
Symbol Name Use
Used to represent the
Terminal
beginning (Start) or the
box
end (End) of a task
Used to connect symbols
Flow line and indicate the flow of logic
Use to declare beginning
Initializatio value
n Box
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Flowcharting
Flowcharting Symbols
Symbols
Symbol Name Use
Used for input and output operations,
Input/output such as reading and printing. The data
box to be read or printed are described
inside.
Flowcharting
Flowcharting Symbols
Symbols
Symbol Name Use
Marker for another process step
Pre-defined or series of process flow steps
process that are formally defined
elsewhere.
On-page Allows flowchart to be
connector continued on the same page.
Off-page Allows the continuation on
connector other pages.
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Start
Start and
and End
End Operation
Operation
Flowchart
Signifies the start and end of
START
the flowchart
END
Pseudocode
Start Program
.
.
End Program
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Variable
Variable Declaration
Declaration
Flowchart
X = 11
PI = 3.1416
Pseudocode
Set x to 11
Set PI to 3.1416
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Input
Input Operations
Operations
Flowchart
INPUT READ
or
A, B A, B
Pseudocode
INPUT A; READ A;
or
INPUT B; READ B;
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Output
Output Operations
Operations
Flowchart
OUTPUT WRITE
or
A, B A, B
Pseudocode
OUTPUT A; WRITE A;
or
OUTPUT B; WRITE B;
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Sequential
Sequential Operation
Operation
Flowchart
• Sequential is very simple design.
• It does not involve conditional or
iterative processing.
• Design in this type is normally from
top to bottom or left to right.
Pseudocode
Start
Process 1
Process 2
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 11
Design a flowchart and
pseudocode that will accept two
numbers and display the
computed sum and product.
Start
Set A, B, Sum, product to 0
Input A, B
Find A + B and assign to Sum
Find A * B and assign to Product
Display Sum, Product
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Conditional
Conditional Operation
Operation
Flowchart
• A step where a decision must be
made
• Ask questions and choose actions
based on the available options
Pseudocode
Start
if condition is true then
process 1
else
process 2
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 22
Create a flowchart and pseudocode to determine
if the password is correct. The correct password is
123
Start
Set PASSWORD to 0
Input PASSWORD
IF PASSWORD is equal to 123
Display “PASSWORD is correct”
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 33
Create a flowchart and
pseudocode to determine if a
number is odd or even.
Start
Set NUM to 0
Input NUM
IF NUM mod 2 is equal to 0
Display “NUM is Even”
else
Display “NUM is Odd”
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 44
Create a flowchart and
pseudocode to determine if a
number is less than, equal or
greater than 0.
Start
Set NUM to 0
Input NUM
IF NUM is less than to 0
Display “NUM is less than zero”
else IF NUM is greater than to 0
Display “NUM is greater than zero”
else
Display “NUM is equal to zero”
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Case
Case Structure
Structure Operation
Operation
• A more convenient way to handle multiple
selections or multiple alternative.
Pseudocode Flowchart
Start
case 1: proces1
case 2: process2
.
.
case n: process n
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 55
Example
Example 55 flowchart
flowchart
Create a flowchart and
pseudocode to determine
the corresponding year level
of a student.
1 – Freshman
2 – Sophomore
3 – Junior
4- Senior
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Repetition
Repetition Operation
Operation
• The loop mechanism causes repetition of a sequence
of statement/s based on the given condition/s. Most of
the time, when a body of the loop is executed, the
value of at least one variable changed. Therefore, most
loop mechanism has cumulative effect.
Repetition
Repetition Operation
Operation
Flowchart
Pseudocode
Start
loop
Process A
while A is not equal to the required value
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 77
Create a flowchart and
pseudocode to print your name
10 times.
Start
set X to 1
set NAME to null
input NAME
while x is less than or equal to 10
Display NAME
increment value of x by 1
loop
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 77
Create a flowchart and
pseudocode to print your name
10 times.
Start
set X to 1
set NAME to null
input NAME
loop
Display NAME
increment value of x by 1
while x is less than or equal to 10
End
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Function
Function Call
Call Operation
Operation
• Depicts a sub-process or sub-routine
Pseudocode Flowchart
Start function(a,b)
process 1
process 2
End function
Function main
.
call function(a,b)
.
End function
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 88
Pseudocode
Start AVERAGE(a, b) Start
set sum, result to 0 set a, b to 0
add a and b and store it to sum input a, b
divide sum by 2 and store in result call AVERAGE(a, b)
display result End
return to main
End function
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Example
Example 88 flowchart
flowchart
Create a flowchart
and pseudocode to
call a function that
will compute for the
average of 2
numbers
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Any
Questions?
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Need
Need Further
Further Clarification?
Clarification?
Create a thread to BB Discussion Board in
the ICS2602 Course Site
Any
Any Concerns?
Concerns?
Send an email to:
DOMAIN EMAIL ADDRESS
UST Domain cdladao@ust.edu.ph
IICS Domain cdladao@ust-ics.mygbiz.com
Artist: TpdkDesign.net
Iconset: Refresh Cl Icons (258 icons)
License: Free for non-commercial use.
Commercial usage: Not allowed
Readme file: readme_eng.txt
Image: www.pexels.com