WK3 Lesson3
WK3 Lesson3
Presentation by
MANZA JOSHUA KIILU
OBJECTIVES
By the end of the lesson the trainee
should be able to:
Describe the following program design tools
FLOWCHARTS
PSEUDOCODE
DECISION TABLES
DECISION TREES
MANZA JOSHUA
3 GROUP PRESENTATIONS ON
PROGRAMMING APPROACHES
GROUP 1
GROUP2
GROUP3
N/B Each to present for 10 minutes
MR MANZA 02/05/2025
Algorithms can be illustrated
using the following tools:
Pseudo codes.
Flowcharts.
Decision Tables.
Decision Trees.
Individual task(recap of pseudocode)
Write a Pseudocode that would prompt the user
to enter the Length and Width of a rectangle,
calculate the Area, then display the result.
Solution
MANZA JOSHUA
Program Control structures
Control structures are blocks of statements that determine how program
statements are to be executed.
They define the flow of a program
In Sequence control, the computer reads instructions from a program file line-by-line starting
from the first line sequentially towards the end of the file. This is called Sequential program
execution.
Note. Sequential program execution enables the computer to perform tasks that are arranged
consecutively one after another in the code.
SELECTION (DECISION) CONTROL
STRUCTURES
Selection involves choosing a specified group of instructions/statements
for execution.
In Selection control, one or more statements are usually selected for
execution depending on whether the condition given is True or False.
IF – THEN
IF – THEN – ELSE
Nested IF
CASE – OF
IF – THEN
IF – THEN structure is used if only one option is available, i.e., it is used to perform a certain
action if the condition is true, but does nothing if the condition is false.
The general format of the IF-THEN structure is:
FALSE
Condition?
TRUE
Continuation of program
Example 1;
In a school, the administration may decide to reward only those students who attain a mean mark
of 80% and above.
Flowchart
Pseudocode
IF Mark > 80 THEN
Print “ Give reward” Mark Yes
ENDIF > 80
Print reward
Stop
IF – THEN -ELSE
The IF-THEN-ELSE structure is suitable when there are 2 available options to select from.
The general format of the IF-THEN-ELSE structure is:
IF < Condition > THEN
Statement 1; (called the THEN part)
ELSE
Statement 2; (called the ELSE part)
ENDIF (indicates the end of the control structure)
The diagrammatic expression of the IF-THEN-ELSE structure is:
TRUE FALSE
Condition?
Print medal
The CASE structure
CASE-OF allows a particular group of statements to be chosen from several available groups.
It is therefore used where the response to a question involves more than two choices/alternatives.
The general format of the CASE structure is:
CASE Expression OF
Label 1: statement 1
Label 2: statement 2
Label 3: statement 3
.
.
.
Label n: statement n
ELSE
Statement m
ENDCASE
ITERATION (LOOPING / REPETITION) CONTROL STRUCTURES
Looping refers to the repeated execution of the same sequence of statements to process
individual data. This is normally created by an unconditional branch back to a previous/earlier
operation.
The loop is designed to execute the same group of statements repeatedly until a certain condition
is satisfied.
Note. Iteration is important in situations where the same operation has to be carried out on a set
of data many times.
Discuss on types of loops)
5 minutes
Lesson review (5 minutes)
INDIVIDUAL ASSIGNMENTS
QUESTION1