4-12、设有程序段: switch(grade) { case ‘A’: printf(“85-100\\”); case ‘B’: printf(“70-84\\”); case ‘C’: printf(“60-69\\”); case ‘D’: printf(“<60\\”); default: printf(“error!\n”); } 若grade的值为‘C’,则输出结果是________。
举一反三
- 若输入B,以下程序的运行结果为()。main(){chargrade;scanf("%c",&grade);switch(grade){case'A':printf(">=85");case'B':case'C':printf(">=60");case'D':printf("<60");default:printf("error");}}(5.0分)
- #include main()_ { char grade=’C’; switch(grade) { case ‘A’: printf(“90-100\n”); case ‘B’: printf(“80-90\n”); case ‘C’: printf(“70-80\n”); case ‘D’: printf(“60-70\n”); break; case ‘E’: printf(“<60\n”); default : printf(“error!\n”); } } 运行结果为( )
- 若输入B,以下程序的运行结果为。 main() {char grade;scanf("%c",&grade); switch(grade) {case'A':printf(">=85."); case'B': case'C':printf(">=60."); case'D':printf("<60."); default:printf("error."); } }
- 下面程序段的输出结果是______。 int n= int n='c'; switch(n++) {default: printf("error"); break; case 'a': case 'A': case 'b': case 'B': printf("good"); break; case 'c': case 'C': printf("pass"); case 'd': case 'D': printf("warn"); }
- switch(a){ case 1:printf(“Monday\n"); case 2:printf("Tuesday\n"); case 3:printf(“Wednesday\n"); case 4:printf("Thursday\n"); case 5:printf("Friday\n");break; case 6:printf("Saturday\n"); case 7:printf("Sunday\n"); } 若a的值为6,请问运行结果为: