At the end of this
topic, you will be able
to:
Learning
Objective • Represent an algorithm
using IPO, pseudocode and
a flowchart for conditional
statements.
3
Algorithm Representation
IPO (Input–Process–Output)
All programs follow three steps:
enter data (INPUT)
process it (PROCESS)
show the result (OUTPUT)
Ways to Show Algorithms:
1. Pseudocode (easy-to-read instructions):
• Uses English-like phrases to describe the steps
of processing.
• Not strictly standardized; each programmer can
write it in their own style.
• Popular because it is easy to revise.
2. Flowchart (visual diagrams):
• Uses standardized symbols like shapes and
arrows to show steps.
• Less used today because it is harder to update.
Flowchart Symbol and Description
Name Symbol Description
Indicates the start or end of a flowchart
Lozenge/Oval
(Start/Stop: Terminal).
Connector Used to connect a break in the flowchart.
Parallelogram Used for input and output operations (data).
Indicates any intermediate operation
Rectangle
(process).
Used for asking questions that can have
Diamond either TRUE or FALSE / YES or NO answers
(Decision/Selection).
Control flow Shows the flow direction.
Flowchart Logic Structure
Sequence Structure Selection Structure Loop Structure
Yes IF No
(test
statement
condition)
LOOP
THEN ELSE (statement)
(statement) (statement)
statement
DO WHILE Yes
(test
condition)
No
DO WHILE
Do steps in order. Make a choice based on a condition. Repeat steps until the task is complete.
Sequence Example
Flowchart
Simple
Simple Design
Design Modular Design Modular Sub-Module
Design
Start
start Start
Read Read
num1 num2
Return
Read num1,
get_input()
num2
Start
calculate sum calculate_sum()
calculate sum
Return
Print sum display_output()
Start
end End Print sum
Return
One straight path of steps. Divide the program into main modules. Break modules into smaller tasks for clarity.
Sequence Example
PseudoCode
Simple Design Modular Design
Modular Design
Simple Design 1. Start
2. get_input()
1. Start 3. calculate_sum()
2. Get input 4. display_output()
Read num1 5. End
Read num2
3. Calculate sum 2. get_input()
sum = num1 + num2 Read num1
4. Display output Read num2
Print sum
5. End 3. calculate_sum()
sum = num1 + num2
4. display_output()
Print sum
Follow steps one by one in order. Break tasks into small “mini-programs” to make the main
program easier to understand and maintain.
Pseudocode Style
Style 1 Style 2 Style 3 (Modular design)
Problem
Problem 1. Start
1. Start 2. Sub-problem 1
2. Sub-problem 1 3. Sub-problem 2
Problem Task 1,1 4. End
1. Start Action 1,1,1
2. Task Action 1,1,2 2. Sub-problem 1
3. Action 3. Sub-problem 2 Task 1,1
4. End Task 1,2 Action 1,1,1
Action 1,2,1 Action 1,1,2
Action 1,2,2
4. End 3. Sub-problem 2
Task 1,2
Simple, linear steps. Structured with blocks for clarity. Modular, divides tasks into reusable subroutines.
Design an algorithm to find the area of a rectangle
The formulas: area = length * width
Pseudocode Example Input
Input variable:
Process
Processing item:
Output
Output:
length area area
width
Start Formula:
Read length area = length x width
Read width
Calculate area of a rectangle Step / Solution algorithm:
get input
Display area of a rectangle
calculate area
End
display output
Start
Input length
OR Input width
Calculate area of a rectangle
Output area of a rectangle
End
Start
Prompt the user to enter a length of a rectangle
OR Prompt the user to enter a width of a rectangle
Calculate the area of a rectangle
Display the area of a rectangle
End
Flowchart Example – IF ELSE Statement
Design an algorithm that inputs two numbers and outputs
whether the first number is greater than or less than the second.
Input Process Output
Input variable: Processing item: Output:
num1, num2 Compare num1 num1 is greater than num2
with num2 or
num1 is less than num2
PSEUDOCODE
START
INPUT num1, num2
IF num1 > num2 THEN
OUTPUT "num1 is greater than num2"
ELSE
OUTPUT "num1 is less than num2"
END IF
END
Flowchart Example – IF ELSE-IF ELSE Statement
Design an algorithm to check whether a number is positive,
negative or zero.
Input Process Output
Input variable: Processing item: Output:
number • If number > 0 → Posi ve Positive,
• If number < 0 → Nega ve Negative or
• Else → Zero Zero
PSEUDOCODE
START
OUTPUT "Enter a number: "
INPUT number
IF number > 0 THEN
OUTPUT "Positive"
ELSE IF number < 0 THEN
OUTPUT "Negative"
ELSE
OUTPUT "Zero"
END IF
END
Flowchart Example – SWITCH Statement
Design an algorithm that accepts a day number and displays the
corresponding APRIL 2025 holiday for days 9, 17, 18 and 19 or outputs that
there is no holiday if the day does not match any of these.
Input Process Output
Input variable: Processing item: Output:
day (a number) Check the value of day using cases 9, Corresponding holiday name or
17, 18, 19; otherwise use default “No holiday on this day!”
PSEUDOCODE
START
INPUT day
SWITCH (day)
CASE 9:
OUTPUT "Araw ng Kagitingan"
BREAK
CASE 17:
OUTPUT "Maundy Thursday"
BREAK
CASE 18:
OUTPUT "Good Friday"
BREAK
CASE 19:
OUTPUT "Black Saturday"
BREAK
DEFAULT:
OUTPUT "No holiday on this day!"
BREAK
END SWITCH
END
Flowchart Example – LOOP Statement
Design an algorithm that outputs all numbers from 1 up to a number entered by
the user.
Input Process Output
Input variable: Processing item: Output:
Number Initialize i = 1; Output values of i
Loop until i > Number
PSEUDOCODE
START
INPUT Number
i=1
WHILE i <= Number DO
OUTPUT i
i=i+1
END WHILE
END