case1
时间: 2024-02-28 19:53:25 浏览: 40
案例一(案例)
In a switch statement, "case 1" is a label used to specify a possible value for the input variable being evaluated.
Here is an example switch statement with a "case 1" label:
```
switch(x){
case 1:
printf("x is equal to 1");
break;
case 2:
printf("x is equal to 2");
break;
default:
printf("x is not equal to 1 or 2");
break;
}
```
In this example, if the value of x is equal to 1, the switch statement will print "x is equal to 1". If x is equal to 2, it will print "x is equal to 2". If x is not equal to either 1 or 2, it will print "x is not equal to 1 or 2".
The break statements are used to exit the switch statement once a case has been matched. If a break statement is not included after a case label, the code will continue to execute the following case statements until it reaches a break statement or the end of the switch statement.
阅读全文