Have always felt that the switch statement is superfluous, do not care how much. In some cases, however, the switch statement can actually save a lot of energy.
When there are multiple judgments, switch can improve the readability of the program,
The form of a switch statement:
Switch (< expression e>) { case < constant expression v1>: [statement S1]; Case < constant expression v2>: [statement S2]; ... .... Case < constant expression vn>: [statement SN]; default: [statement sn+1]; }
When the value of the expression E is equal to the value of one of the constant expressions in the case, all statements following the colon in the case are executed until the break statement jumps out.
If the case does not satisfy the value of the expression E, execute the statement after default, and if there is no default statement, jump out of the loop.
E can be an int float and other types ....
Summary of Switch statements