C语言教程:switch语句从多个条件执行代码
C语言中的switch
语句用于从多个条件执行代码。 就像if else-if
语句一样。
C语言中switch
语句的语法如下:
switch(expression){
case value1:
//code to be executed;
break; //optional
case value2:
//code to be executed;
break; //optional
......
default:
code to be executed if all cases are not matched;
}