Fortune Telling Collection - Horoscope - The use of c language switch

The use of c language switch

C language switch is used to select and execute the corresponding statement sequence according to the value of the expression. The usage of C language switch includes:

1, switch (expression). Where the expression is usually an integer or a character variable.

2.case constant expression. The rest. case statement is used to specify that the statement after case is executed when the value of the expression is equal to the value of the constant expression. If there is no break statement, the program will continue to execute the statement of the next case.

3, case constant expression, statement 2break. You can have any number of case statements.

4. If the value of the expression without any case matches the value of the expression, the statement after default is executed.