Learning outcome c) COUNTER-CONTROLLED REPETITION – WITH n NUMBER OF TIMES Terms
1.0 Problem Solving Initialization – Initial value of the accumulator Definition : Used to tell a
1.3.6 Algorithm – Pseudocode →set sum/total = 0 program to execute
statements repeatedly.
1.3.6.1 Solve a given problem using (before condition)
A counter variable is any
pseudocode RULES : Input –Input / Read value of n numeric variable used to
count the number of
LY2020001226 • Repetition / Looping Four elements →Read n WATCH ME! times a loop has occurred
that are required (before condition) that can be counted by
incrementing or
a) INTRODUCTION TO REPETITION WATCH ME! to perform decrementing its value.
counter-
An accumulator is the
Two types of repetition controlled variable used to keep the
total of a series of
Counter-controlled Repetition Sentinel-controlled Repetition repetition with n Condition – Test the loop control variable numbers or An
of times whether the loop should continue or stop accumulator is a numeric
variable used to total or
A counter-controlled loop repeats a A sentinel-controlled loop uses a (IICU) accumulate values.
specific number of times - User sentinel value to stop a loop - User
knows exactly or user can enter how uses special input value to signifies Update Counter – Could be increment or Infinite loop : a loop that
many times the loop body need to be the end of the input decrement where the value of the loop control never stops executing.
executed variable is updated (before endwhile)
Quick Access
b) COUNTER-CONTROLLED REPETITION d) COUNTER-CONTROLLED REPETITION - ACCUMULATE
Initialization – WATCH ME! Initialization – Initial value WATCH ME!
Initializes the loop’s of the accumulator
control variable →set sum/total = 0
(before condition) (before condition)
RULES : Condition – Test Quick Access RULES : Formula – Update Quick
the loop control the value that is Access
Three elements variable whether Three elements held by
that are required to the loop should that are required accumulator
continue or stop → sum = sum + ___
perform counter- to perform
controlled Update Counter – Could accumulation (before update
repetition be increment or counter)
decrement where the (IFP)
(ICU) value of the loop control *Print – Print the value that
variable is updated is held by accumulator OR
(before endwhile) calculate the formula of
average
→ print sum
(after endwhile)
Learning outcome (SES) Terms
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode Definition : Used to
tell a program to
1.3.6.1 Solve a given problem using pseudocode execute statements
• Repetition / Looping repeatedly.
a) INTRODUCTION TO REPETITION A counter variable is
any numeric
Two types of repetition variable used to
count the number
Counter-controlled Repetition Sentinel-controlled Repetition of times a loop has
occurred that can be
A counter-controlled loop repeats a specific A sentinel-controlled loop uses a sentinel counted by
number of times - User knows exactly or user value to stop a loop - User uses special input incrementing or
can enter how many times the loop body need value to signifies the end of the input decrementing its
to be executed value.
Quick Access An accumulator is
the variable used to
WATCH ME! keep the total of a
series of numbers or
LY2020001226 An accumulator is a
numeric variable
used to total or
accumulate values.
Infinite loop : a loop
that never stops
executing.
Learning outcome (SES) WATCH ME!
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode LY2020001226
1.3.6.1 Solve a given problem using pseudocode
• Repetition / Looping
b) COUNTER-CONTROLLED REPETITION
RULES : Initialization – Initializes the loop’s
control variable
Three elements that (before condition)
are required to
perform counter- Condition – Test the loop control
variable whether the loop should
controlled repetition continue or stop
(ICU) Update Counter – Could be increment
or decrement where the value of the
loop control variable is updated
(before endwhile)
Learning outcome (SES)
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode
1.3.6.1 Solve a given problem using pseudocode
• Repetition / Looping
c) COUNTER-CONTROLLED REPETITION – WITH n NUMBER OF TIMES
Initialization – Initial value of the
accumulator
→set sum/total = 0
(before condition)
RULES : Input –Input / Read value of n
→Read n
Four elements that (before condition)
are required to
perform counter- Condition – Test the loop control
controlled variable whether the loop should
continue or stop
repetition with n of
times Update Counter – Could be increment or
decrement where the value of the loop
(IICU) control variable is updated (before endwhile)
WATCH ME!
LY2020001226
Learning outcome (SES) WATCH ME!
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode Quick Access
1.3.6.1 Solve a given problem using pseudocode LY2020001226
• Repetition / Looping
d) COUNTER-CONTROLLED REPETITION - ACCUMULATE
Initialization – Initial value of the
accumulator
→set sum/total = 0
(before condition)
RULES : Formula – Update the value that
is held by accumulator
Three elements that → sum = sum + ___
are required to (before update counter)
perform accumulation *Print– Print the value that is held by
accumulator OR calculate the formula of
(IFP) average
→ print sum
(after endwhile)
e) COUNTER-CONTROLLED REPETITION (FREQUENCY) WATCH ME! g) SENTINEL-CONTROLLED REPETITION (MAXIMUM) WATCH ME!
RULES : Initialization – RULES : Initialization – Initial value of
Initial value of the the maximum (set as lowest
Three elements frequency Three elements value)
that are required →set freq = 0 that are required →set max = 0 / -99999
(before condition)
to perform (before condition) to perform
frequency maximum Formula - compare the variable
Formula – Update with initial value of maximum
(IFP) the value of (IFP) → if ( variable > max)
frequency that is
held by freq max = variable
→ freq = freq + 1 endif
(before update input)
(before update
counter) *Print– Print the value that is
held by maximum
*Print– Print the → print max
value that is held by (after endwhile)
freq
→ print freq
(after endwhile)
f) SENTINEL-CONTROLLED REPETITION WATCH ME! h) SENTINEL-CONTROLLED REPETITION (MINIMUM) WATCH ME! Quick Access
RULES : Prime Input – RULES : Initialization – Initial value of the
Initializes the loop’s minimum (set as highest value)
Three elements control variable Three elements →set min = 100 / 99999
that are required to that are required (before condition)
Condition – Test
perform counter- the loop control to perform Formula – compare the variable with
controlled variable whether minimum initial value of minimum
repetition the loop should → if ( variable > min)
continue or stop (IFP)
(PCU) min = variable
Update Counter – endif
Could be increment (before update input)
or decrement
where the value of *Print– Print the value that is
the loop control held by minimum
variable is updated → print min
(after endwhile)
Learning outcome (SES)
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode
1.3.6.1 Solve a given problem using pseudocode
• Repetition / Looping
e) COUNTER-CONTROLLED REPETITION (FREQUENCY)
Initialization – Initial value of the frequency WATCH ME!
→set freq = 0
Quick Access
(before condition)
LY2020001226
RULES : Formula – Update the value of
frequency that is held by freq
Three elements that → freq = freq + 1
are required to
(before update counter)
perform frequency
(IFP)
*Print– Print the value that is held by frequency
→ print freq
(after endwhile)
Learning outcome (SES)
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode
1.3.6.1 Solve a given problem using pseudocode
• Repetition / Looping
f) SENTINEL-CONTROLLED REPETITION
RULES : Prime Input – Initializes the loop’s control WATCH ME!
variable
Three elements that Quick Access
are required to Condition – Test the loop control
perform counter- variable whether the loop should LY2020001226
controlled continue or stop
repetition
Update Counter – Could be increment or
(PCU) decrement where the value of the loop control
variable is updated
Learning outcome (SES) WATCH ME!
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode Quick Access
1.3.6.1 Solve a given problem using pseudocode LY2020001226
• Repetition / Looping
g) SENTINEL-CONTROLLED REPETITION (MAXIMUM)
Initialization – Initial value of the
maximum (set as lowest value)
→set max = 0 / -99999
(before condition)
RULES : Formula - compare the variable
with initial value of maximum
Three elements that → if ( variable > max)
are required to
max = variable
perform maximum
endif
(IFP)
(before update input)
*Print– Print the value that is held by
maximum
→ print max
(after endwhile)
Learning outcome (SES)
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode
1.3.6.1 Solve a given problem using pseudocode
• Repetition / Looping
h) SENTINEL-CONTROLLED REPETITION (MINIMUM) WATCH ME!
Initialization – Initial value of the minimum Quick Access
(set as highest value)
→set min = 100 / 99999 LY2020001226
(before condition)
RULES : Formula – compare the variable with
initial value of minimum
Three elements that → if ( variable > min)
are required to
min = variable
perform minimum
endif
(IFP)
(before update input)
*Print– Print the value that is held by minimum
→ print min
(after endwhile)
Learning outcome (SES)
1.0 Problem Solving
1.3.6 Algorithm – Pseudocode
1.3.6.1 Solve a given problem using pseudocode
• Repetition / Looping
i) SENTINEL-CONTROLLED REPETITION (FREQUENCY)
RULES : Initialization – Initial value of the frequency WATCH ME!
→set freq = 0
Three elements that (before condition) LY2020001226
are required to
Formula – Update the value of
perform frequency frequency that is held by freq
→ freq = freq + 1
(IFP) (before update input)
*Print– Print the value that is held by frequency
→ print freq
(after endwhile)