The switch statement causes control to be transferred to one of several statements depending on the value of an expression. It has the form
switch ( expression ) statement
The statement is typically compound. Any statement within the statement may be labelled with one or more case prefixes as follows:
case constant : statement
There may also be prefix of the form:
default : statement
When the switch statement is
executed, its expression is evaluated and compared with each
case constant. If one of the
case constants is equal to the value
of the expression, control is passed to the statement following
the matched case prefix. If no
case constant matches the expression,
and there is a default prefix, control
passes to the prefixed statement. If no case
matches and if there is
no default then none of the statements in
the switch is executed.