IMind soft

Author's software

Development

Design

Designing

Being tested

Operators switch, default, case, break

Writing:

switch (<the variable or expression>)

{

case <value>:

<the statement block>;

break;

case <value>:

<the statement block>;

break;

...

...

default:  // The default value

<the statement block>;

}

 

The switch statement is used to select one value from multiple values and execute the appropriate code going after the case statement, such that the value of a variable in the switch statement and is in the case statement coincided.

The break statement is used to exit the switch statement without it will execute the next statement, even if this is the case - they will be executed, until not meet the break statement or the end of the switch statement block.

Top.Mail.Ru