switch
1 #include <stdio.h>
2
3 int main () {
4 /* local variable definition */
5 char grade = 'A';
6 switch(grade) {
7 printf("Never excute\n" );
8 case 'A' :
9 printf("Excellent!\n" );
10 break;
11 case 'D' :
12 printf("You passed\n" );
13 break;
14 case 'F' :
15 printf("Better try again\n" );
16 break;
17 default :
18 printf("Invalid grade\n" );
19 }
20 return 0;
21 }
说明:第7行这条语句不会被执行。