#include<stdio.h>
main()
{
float score,grade;
char A,B,C,D,E;
printf("Input score:");
scanf("%f",&score);
if (score>=90&&score<=100) grade=A;
{
printf("%c",grade);
}
else if (score>=80&&score<90) grade=B;
{
printf("%c",grade);
}
else if(score>=70&&score<80) grade=C;
{
printf("%c",grade);
}
else if(score>=60&&score<70) grade=D;
{
printf("%c",grade);
}
else if(score>=0&&score<60) grade=E;
{
printf("%c",grade);
}
return 0;
}
老是提示有错求大神指导 明天交作业了啊啊啊!!!!!!!
#include<stdio.h>
void main()
{
float score;
char a='A',b='B',c='C',d='D',e='E',grade;
printf("Input score:\n");
scanf("%f",&score);
if (score>=90&&score<=100)
printf("%c\n",grade=a);
else if (score>=80&&score<90)
printf("%c\n",grade=b);
else if(score>=70&&score<80)
printf("%c\n",grade=c);
else if(score>=60&&score<70)
printf("%c\n",grade=d);
else if(score>=0&&score<60)
printf("%c\n",grade=e);
else if(score>100||score<0)
printf("成绩出错\n");
}
字符常量只能用单引号括起来,改了就好了grade='A'等是可以省的;
如果成绩输错可以显示,保证程序的完备性;
希望可以帮到你!