You are on page 1of 3

Summer School

July 18th, 2019


Information Technology

Topic:​ Problem Solving - Control Structure

Iteration/Repetition/Loop

This refers to the repetition stage of the processing step. This is because there will be times
when we have to repeat a process.

For example, if we were required to accept 100 numbers, instead of writing the instruction 100
times, we would just repeat the process 100 times.

Bounded Iteration

This is used when we are doing a process a fixed number of times.

Unbounded Iteration

This is used when we are doing a process until a specific condition is met.

Activity:

Create an algorithm that will read three number and find the largest.

Step 1: Start
Step 2: Input num 1, num 2, num 3
Step 3: Read num 1, num 2, num 3
Step 4: If num 1 > num 2, then
larger ← num 1
larger ← num 2
endif
Step 5: If larger > num 3 then
largest ← larger
else
largest ← num 3
endif
Step 6: Display largest
Step 7: Stop

Write a Pseudocode that will accept three unequal numbers and find the smallest among them.
Step 1: Start
Step 2: Input num 1, num 2, num 3
Step 3: Read num 1, num 2, num 3
Step 4: If num 1 < num 2 then
smaller ← num 1
else
smaller ← num 2
endif
Step 5: If smaller < num 3 then
smallest ← smaller
else
smallest ← num 3
elseif
Step 6: Display smallest
Step 7: Stop

Selection Statements

This is used in problems with instructions to be carried out if a certain condition is met. The
choice of options will be dependent on whether the condition is true or false. Selection control
structure commonly used in algorithm are normally written as: if(condition) then (instructions to
be performed if the condition is true) else (instructions to be performed if the condition is false)
example:

Step 1: Start
Step 2: Accept score
Step 3: If score is more than 59 then display 'the student has passed' else display 'the student
has failed'
Step 4: Stop

In the example given above, only one of the two messages can be displayed.

Sequence

This is used when you have instructions to be carried out in a particular order. Instructions can
be written in the order you want it to happen. The instructions will be completed in the order
given. This control structure is used for problems involving accepting inputs, performing
calculations and storing them and displaying outputs. Example:

Step 1: Start
Stsp 2: Get two numbers
Step 3: Add the numbers and store the result in answer.
Step 4: Display answer
Step 5: Stop

You might also like