
Control Structures 311
11.8 THE switch case STATEMENT
The switch statement is a multi-way branch
statement and an alternative to if-else-if
ladder in many situations. This statement requires
only one argument, which is then checked with
number of case options. The switch statement
evaluates the expression and then looks for its value
among the case constants. If the value is matched
with a case constant then that case constant is exe-
cuted until a break statement is found or end
of switch block is reached. If not then simply
default (if present) is executed (if default
isn’t present then simply control flows out of the
switch block). The ...