COMP1. L4. Selection Control Structure
COMP1. L4. Selection Control Structure
SELECTION
CONTROL
STRUCTURE
BEGIN
SELECTION
CONTROL INPUT
DATA
STRUCTURE
CHECK
⚫ Used to test a DATA
condition and
provides for a choice PROCESS PROCESS
of one between two DATA DATA
alternatives
OUTPUT OUTPUT
DATA DATA
END
SELECTION CONTROL STRUCTURE
e.g.
1. Make a flowchart that will accept as input
a speed of an automobile. Display “over
speeding” if the speed is more than 60
kph. Else, display “normal speed”.
1. START
Speed = 0
Speed
Speed > N
60
Y
“Over speeding” “Normal
speed”
END
e.g.
2. Given the numbers X, Y and Z; prepare a
flowchart to determine and print the
following:
a. If X is greater than Y, then print Z.
b. If X is greater than Z, then print the
difference between Y and Z.
c. If X is equal to 100, then print the
sum of the numbers.
2. START
X = 0, Y = 0, Z = 0
SUM = 0, DIFF = 0
X Y Z
Y
X>Y Z
N
Y
X>Z DIFF = Y - Z DIFF
N
Y
X = 100 SUM = X + Y + Z SUM
A N
A
END
EXERCISES