You are on page 1of 34

INSTITUTE OF INFORMATION AND COMPUTING

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.

St. Vincent Ferrer , Pray for us.


St. Thomas Aquinas, Intercede for us.
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

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:

Understand the basic flowcharting symbols

Demonstrate how to write a pseudocode

Demonstrate how to write a flowchart


INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

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.

Used for arithmetic and data-


manipulation operations. The
Processing instructions are listed inside the
symbol.

Used for any logic or comparison


operations. The path chosen depends
Decision Box on whether the answer to a question
is “yes” or “no.” or “True” or “False”
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

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

Create a flowchart and Start


pseudocode to determine Set YEARLEVEL to 0
Input YEARLEVEL
the corresponding year
Switch (YEARLEVEL)
level of a student. case 1: Display “Freshman”
1 – Freshman case 2: Display “Sophomore”
case 3: Display “Junior”
2 – Sophomore case 4: Display “Senior”
3 – Junior default: Display “Invalid”
End
4- Senior
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

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.

• Counter – a variable used to determine number of


loops
• Accumulator – a variable use to store results of an
iteration
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

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

Create a flowchart and pseudocode to call a function


that will compute for the average of 2 numbers

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

IMPORTANT: The Blackboard Discussion Board is a learning space. Let us


use the BB Discussion Board for learning purposes for the benefit of the entire
class. Use decent words when you create a thread. Also, sending personal
message to your classmate is prohibited.
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

Any
Any Concerns?
Concerns?
Send an email to:
DOMAIN EMAIL ADDRESS
UST Domain cdladao@ust.edu.ph
IICS Domain cdladao@ust-ics.mygbiz.com

Get in touch with the IICS Office


through
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES

Thank you and Keep


Safe!
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Image Citation:
Image Details
Agenda icon, www.okcareertech.org

Artist: Double-J Design (Available for custom work)


Iconset: Ravenna 3D Icons (90 icons)
License: CC Attribution 4.0
Commercial usage: Allowed (Backlink to http://www.doublejdesign.co.uk
 required)
Readme file: readme.txt
Artist: Hopstarter (Available for custom work)
Iconset: Soft Scraps Icons (150 icons)
License: CC Attribution-Noncommercial-No Derivate 4.0
Commercial usage: Allowed (Author Arrangement required -> Visit artist
website for details).
Artist: FixIcon
Iconset: The Lords Applications Icons (10 icons)
License: Free for personal desktop use only.
Commercial usage: Not allowed
Readme file: More_Icons.html
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Image Citation:
Image Details
Artist: Icons8
Iconset: iOS 7 Icons (1738 icons)
License: Linkware (Backlink to http://icons8.com required)
Commercial usage: Allowed
License URL: http://icons8.com/license/
Artist: Untergunter
Iconset: Leaf Mimes Icons (67 icons)
License: CC Attribution-Noncommercial-Share Alike 4.0
Commercial usage: Not allowed

Artist: Hopstarter (Available for custom work)


Iconset: Sleek XP Basic Icons (50 icons)
License: CC Attribution-Noncommercial-No Derivate 4.0
Commercial usage: Allowed (Author Arrangement required -> Visit artist
website for details).
Artist: Aroche
Iconset: Delta Icons (175 icons)
License: CC Attribution-Noncommercial-No Derivate 4.0
Commercial usage: Not allowed
INSTITUTE OF INFORMATION AND COMPUTING
SCIENCES
Image Citation:
Image Details
Artist: BlackVariant
Iconset: Button UI System Apps Icons (72 icons)
License: Free for non-commercial use.
Commercial usage: Not allowed

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

Background: Computer Programming Wallpaper,


www.wallpaperaccess.com

You might also like