3.4.5 switch-case-break-end_switch
Description
A switch statement evaluates a numeric expression and compares it with the resulting value of the numeric expression designated by a case statement. It is executed from the case statement of equal value until a break statement is encountered.
In the following example, if the resulting value of Expression X is equal to the resulting value of Expression B1 or B2, (1) through (3) will be executed, and it will move to the point of the end_switch statement (note that there is no break below the command statement B). Meanwhile, if the resulting value of Expression X is equal to that of Expression C, (2) through (3) will be executed.
If the resulting value of Expression X is not equal to that of any case statement, it will be moved to the default, and (4) through (5) will be executed. Then, the default section may be omitted.
Syntax
Any expressions such as Boolean, numeric, string constant, parameter, and numeric, are permissible.
Example
Last updated
Was this helpful?