The Selective Structure : switch

The syntax of the switch instruction is a bit peculiar. Its objective is to check several possible constant values for an expression, something similar to what we did at the beginning of this section with the linking of several if and else if sentences. Its form is the following:
switch (expression)
case constant1:
block of instructions 1
case constant2:
block of instructions 2
break; . . .
default: default block of instructions

No comments: