c/language/switch

Executes code according to the value of an integral argument.

Used where one or several out of many branches of code need to be executed according to an integral value.

Explanation
The body of a switch statement may have an arbitrary number of labels, as long as the values of all  are unique (after  to the  of ). At most one label may be present (although nested switch statements may use their own  labels or have  labels whose constants are identical to the ones used in the enclosing switch).

If evaluates to the value that is equal to the value of one of s after conversion to the promoted type of, then control is transferred to the statement that is labeled with that.

If evaluates to a value that doesn't match any of the  labels, and the  label is present, control is transferred to the statement labeled with the  label.

If evaluates to a value that doesn't match any of the  labels, and the  label is not present, none of the switch body is executed.

The statement, when encountered anywhere in, exits the switch statement:

Keywords
, ,