Mastery17


Mastery17

Mastery17

Use of “switch” as a conditional
The body of a switch statement may have an arbitrary number of case: labels, as long as the values of all constant_expressions are unique (after conversions/promotions). At most one default: label may be present (although nested switch statements may use their own default: labels or have case: labels whose constants are identical to the ones used in the enclosing switch)
If condition evaluates to the value that is equal to the value of one of constant_expressions, then control is transferred to the statement that is labeled with that constant_expression.
If condition evaluates to the value that doesn’t match any of the case: labels, and the default: label is present, control is transferred to the statement labeled with the default: label.
The break statement, when encountered in statement exits the switch statement:
switch(1) {
case 1 : cout #TC1017

CC BY 4.0 Mastery17 by ivanna lases is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.