Use the C switch statement to a large number of values for a single variable or evaluate an expression.
Switch can much be satisfied, a long if else statements string. Level of difficulty: Moderately easyInstructionsCreate a switch statement
- 1
Select the value that determines an action in your switch statement.
It can be only one variable, the result of invoking the function or any expression. Create a switch statement
Select the value that determines an action in your switch statement.
Set this value or an expression after the switch as this statement:
Switch {(Variable)}
Make a list of all the values you want to capture.
It is very common for the values with the # defined constants statement Précompilateur C. define
Include a statement in the box for each value in the following format:
Value of the case:
Follow each statement box with one or more actions.
Type each set of commands with a break statement to start the following case.
Create a sp
{Close with a block}, as in this example:
Switch (Evaluate_color (red, green, blue))
No comments:
Post a Comment