The Case Construct
Used in cases where exactly one of several alternative actions is
selected and performed.
statement sequence n
Selector is an integer, character, or logical
The values in the list may have any of the forms:
(value1: value2) range of values from value1 through
range of values greater than or equal
range of values less than or equal to
print*, ‚error,Illegal code‛
Example: Pollution Index
A case statement can be used to carry
out the classification given (good, fair,
A case statement can be used to
replace an IF / ELSE IF structure.
Range Selectors “Characters”
Print*, ‘Not a letter or number’
What about real valued selectors??
A selector can’t be of type real.
To make a selection, convert the real
number to an integer and then use it
for the selection.
Suppose a motors’ RPM is determined by an indicator x.
normal speed 2.5<= x < 5.5
x < 2.5
print*, ‚HIGH SPEED‛
print*, ‚NORMAL SPEED‛
print*, ‚LOW SPEED‛