Selection Structures 1
Selection Structures 1
RELATIONAL OPERATORS
OPERATOR OPERATION PRIORITY
== Equal to (the same) 1
Equality
!= Not equal to (not the same as) 1
Greater than (more, bigger, larger, higher, longer
> 1
than, exceeds, over)
Relational < Less than (smaller, fewer, lower, shorter than, below) 1
LOGICAL OPERATORS
OPERATOR OPERATION PRIORITY
.NOT. Negation 1
The computer evaluates first the operator with the highest priority (1). For same
priority, evaluation is from left to right. Operations inside parentheses ()
if any are evaluated first.
A B .NOT. A .NOT. B A .AND. B A .OR. B
I = Num
P = Num >= 0, display “Positive Number”
O = Positive Number
PSEUDOCODE FLOWCHART
START
F
if (Num >= 0) Num >= 0
T
“Positive
display “Positive Number” Number”
END
Two – way selection structure
I = Num
P = Num >= 0, display “Positive Number”
otherwise display “Negative Number”
O = Positive Number, Negative Number
PSEUDOCODE FLOWCHART
START
T F
if (Num >= 0) Num >= 0
END
Multiple/Nested-If Selection Structure
I = Temp
P = Temp < 0, display “ICE” Temp <= 100,
display “WATER”, otherwise display
“STREAM”
O = Ice, Water, Stream
PSEUDOCODE FLOWCHART
START
END
Laboratory Exercise