0% found this document useful (0 votes)
21 views26 pages

WK3 Lesson3

The document outlines a lesson on program design tools, including flowcharts, pseudocode, decision tables, and decision trees. It covers control structures in programming, detailing sequence, selection, and iteration, along with examples of IF-THEN, IF-THEN-ELSE, nested IF, and CASE structures. Additionally, it includes an individual task and assignments for further understanding of decision trees and tables.

Uploaded by

jomanzetec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views26 pages

WK3 Lesson3

The document outlines a lesson on program design tools, including flowcharts, pseudocode, decision tables, and decision trees. It covers control structures in programming, detailing sequence, selection, and iteration, along with examples of IF-THEN, IF-THEN-ELSE, nested IF, and CASE structures. Additionally, it includes an individual task and assignments for further understanding of decision trees and tables.

Uploaded by

jomanzetec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

LESSON3 WK3

PROGRAM DESIGN TOOLS

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

 Control statements deal with situations where processes are to be repeated


several number of times or where decisions have to be made.
Also known as program constructs
Types of program control structures
There are 3 control structures used in most of the structured
programming languages:
 Sequence.
 Selection.
 Iteration (looping).
SEQUENCE CONTROL STRUCTURES

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.

Start Statement 1 Statement 2 … Statement n End

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.

 The condition must be a Boolean (logical) expression, e.g., X >= 20


 In this case, the condition is true if x is equal to or greater than 20. Any
value that is less than 20, will make the condition false.
Generally, there are 4 types of selection control structures used in
most high-level programming languages:

 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:

IF < Condition > THEN


Program statement to be executed if condition is true;
ENDIF
If the condition is TRUE, the program executes the part following the keyword ‘THEN’. If
the condition is FALSE, the statement part of the structure is ignored, and the program
continues with the statements below the ENDIF.
The diagrammatic expression of the IF-THEN structure is:

FALSE
Condition?

TRUE

Execute statements between


THEN & ENDIF

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?

Execute statements between Execute statements between


THEN & ELSE ELSE & ENDIF

Execute statements after


ENDIF
Example 1;
In a football match, if a player makes a mistake which is considered serious by the rules of the
game, he/she is given a Red card. Otherwise, he/she is given a Yellow card.
Flowchart
Pseudocode
IF Fault = Serious THEN
Print “ Give red card” No Fault = Yes
Serious
ELSE
Print “ Give Yellow card”
Print Yellow Print Red
ENDIF card card
NESTED IF
Nested IF structure is used where 2 or more options have to be considered to make a selection.
The general format of the Nested IF structure is:
IF < Condition 1 > THEN
Statement 1
ELSE
IF < Condition 2 > THEN
Statement 2
ELSE
IF < Condition 3 > THEN
Statement 3
ELSE
Statement 4;
ENDIF
ENDIF
ENDIF
Example;
In an Olympics track event, medals are awarded only to the first three athletes as follows:
a). Position 1: Gold medal
b). Position 2: Silver medal
c). Position 3: Bronze medal
The pseudocode and flowchart below can be used to show the structure of the Nested IF
selection.
Pseudocode
IF Position = 1 THEN
Medal = “Gold”
ELSE
IF Position = 2 THEN
Medal = “Silver”
ELSE
IF Position = 3 THEN
Medal = “Bronze”
ELSE
Medal = “nil”
ENDIF
ENDIF
ENDIF
Flowchart

Position No Position No Position No


1 2 3
Yes Yes Yes

Medal = Medal = Medal = Medal =


“Gold” “Silver” “Bronze” “Nil”

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

Discuss on decision tree and decision table


THANK YOU

You might also like