Arellano University: SUBJECT Computer Programming I TOPIC Sequence and Selection Structure Reference Objectives
Arellano University: SUBJECT Computer Programming I TOPIC Sequence and Selection Structure Reference Objectives
Name: Date:
Grade/Section: Rating:
Teacher:
OBJECTIVES
a. Understand the Sequence and Selection Structure of Flowchart Program.
b. Identify the difference of Binary Selection and Multi-way Selection
Structure.
CONCEPTS SEQUENCE
In a computer program or an algorithm, sequence involves simple steps which are to
be executed one after the other. The steps are executed in the same order in which
they are written.
Below is an example set of instructions to add two numbers and display the answer.
Pseudocode example:
BEGIN AddTwoNumbers
get firstNumber
get secondNumber
total = firstNumber + secondNumber
Display "The sum of your two numbers is "; total
END AddTwoNumbers
SELECTION
Selection is used in a computer program or algorithm to determine which particular
step or set of steps is to be executed. This is also referred to as a ‘decision’. A
selection statement can be used to choose a specific path dependent on a condition.
There are two types of selection: binary selection (two possible pathways) and multi-
way selection (many possible pathways).
Binary Selection
In binary selection, if the condition is met then one path is taken, otherwise the
second possible path is followed. In each of the examples below, the first case
described requires a process to be completed only if the condition is true. The
process is ignored if the condition is false. In the second case, there is an alternative
process if the condition is false.
Pseudocode example:
IF Raining THEN
Take umbrella
ENDIF
or
IF Raining THEN
Take umbrella
ELSE
Put on suncream
ENDIF
ARELLANO UNIVERSITY
Flowchart example:
Multi-way selection
Multi-way selection allows for any number of possible choices, or cases. The path
taken is determined by the evaluation of the expression. Multi-way selection is often
referred to as a case structure.
Pseudocode example:
CASEWHERE buttonPressed evaluates to
choice a : process1
choice b : process2
OTHERWISE : default process
ENDCASE
Flowchart example:
QUESTIONS/ACTIVITY QUESTIONS:
1. What is Sequence Structure in flowchart program?
2. What is Selection Structure?
3. What is Binary Selection Structure?
4. What is Multi-way Selection?
5. What is the difference between binary and multi-way selection
structure?
6-10 . Make a selection structure using Pseudocode = IPO Outline
ARELLANO UNIVERSITY
input
ASSESSMENT/ Analyze the problems below, create steps or procedure to solve each problem using
APPLICATION Flowchart program of selection structure.
Binary Selection
pseudocode: If then Else
If age > 17
Display a message indicating you can vote.
Else
Display a message indicating you can't vote.
Endif
Multi-way Selection
then Else control structure
pseudocode: Case
Case of age
0 to 17 Display "You can't vote."
18 to 64 Display "You are in your working years."
65 + Display "You should be retired."
End case
ARELLANO UNIVERSITY
Name: Date:
Grade/Section: Rating:
Teacher:
OBJECTIVES
a. Recognize repetition structure.
b. Determine the difference of types of repetition.
CONCEPTS REPETITION
Repetition allows for a portion of an algorithm or computer program to be executed
any number of times dependent on some condition being met. An occurrance of
repetition is usually known as a loop.An essential feature of repetition is that each
loop has a termination condition to stop the repetition, or the obvious outcome is that
the loop never completes execution. This is known as an infinite loop and is
obviously undesirable. The termination condition can be checked or tested at the
beginning or end of the loop, and is known as a pre-test or post-test, respectively.
Following is a description of each of these types of loop.
Repetition pre-test loop
A pre-tested loop is so named because the condition has to be met at the very
beginning of the loop or the body of the loop is not executed. This construct is often
called a guarded loop. The body of the loop is executed repeatedly while the
termination condition is true.
Pseudocode example:
WHILE condition is true
processes
ENDWHILE
Flowchart example:
Pseudocode example:
REPEAT
process
UNTIL condition is true
Flowchart example:
ARELLANO UNIVERSITY
Pseudocode example:
FOR i = 1 to 12 STEP 1
Display "12 x " i " = " (12 * i)
NEXT i
Flowchart example:
QUESTIONS/ACTIVITY QUESTIONS:
1. What is repetition structure?
2. What repetition pre –test loop?
3. What is repetition post-test loop?
4. What is for next or counted loops?
5. What is the use of repetition loop?
6-10.Draw a flowchart which when you put any number will print your name the
same times the inputted number.
ASSESSMENT/ Analyze the problem below, create steps or procedure to solve each problem using
APPLICATION flowcharting symbols, following the guidelines and rules in flowcharting .Use the
appropriate symbols. Draw a flowchart that performs repetition within a program.
Given the amount to be paid for some grocery items purchased by each ten
customers. If the amount exceeds P700, a 10% discount is given, otherwise ,
no discount is given. Print the appropriate amount.