利用if-else语句编程,根据输入的百分制成绩score,转换成相应的五分制成绩grade后输出 老是有错 求指导啊

#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'等是可以省的;

    如果成绩输错可以显示,保证程序的完备性;

希望可以帮到你!

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-10-15
#include<stdio.h>
main()
{
 float score;
 char grade;
 printf("Input score:");
 scanf("%f",&score);
 if (score>=90&&score<=100) grade='A';
 else if (score>=80&&score<90) grade='B';
 else if(score>=70&&score<80) grade='C';
 else if(score>=60&&score<70) grade='D';
 else if(score>=0&&score<60) grade='E';
 else grade='F';
 printf("%c\n",grade);
 return 0;
}

本回答被提问者和网友采纳
第2个回答  2013-10-15
char A,B,C,D,E //是声明字符变量 ,存放的是字符变量 可以让 A=‘A’ B=‘B’。。。。。
然后 将float grade 声明为字符型 : char grade 这样就行了
第3个回答  2013-10-15
你把if之后的那一句话放到输出语句的语句块里面吧!还有grade的类型是什么?你没有指明,要这样写,char grade;
grade = ‘A’;
相似回答