关于C选择结构(switch)
请高手帮忙看一下下面的程序哪里错了:#include<stdio.h>
int main()
{
float score;
char grade;
printf("please printf your score:");
scanf("%f",&score);
while(score>100||score<0)
{
printf("\nprintf is wrong,please printf again");
scanf("%f",&score);
}
switch((int)(score/10))
{
case10:
case9:grade='A';break;
case8:grade='B';break;
case7:grade='C';break;
case6:grade='D';break;
case5:
case4:
case3:
case2:
case1:
case0:grade='E';
}
printf("the score is %5.1f,the grade is %c\n",score,grade);
return 0;
}
(不考虑英语语法错误)
输入56
运行结果是:
the score is 56.0,the grade is
也就是说运行结果没有输出等级,怎么回事呢?