这个程序哪里错了啊??急

来源:百度知道 编辑:UC知道 时间:2024/05/17 23:44:26
#include"stdio.h"
main()
{
float score;char grade;
printf("Please input the score:");
scanf("%f",&score);
if(score>=90);
grade='A';
else if( score>=80);
grade='B';
else if (score>=70);
grade='C';
else if( score>=60);
grade='D';
else
grade='E';
printf("%f,%c\n",score,grade);
}
错误 11.c 9: 'else' 位置错在 main 函数中 这怎么改啊 本人是初学者 书上就这样的格式是对的

if(score>=90);等语句错,将这个分号去掉!
包括
else if( score>=60);
也要将分号去掉
if会执行到其后的一个语句或大括号中的复合语句,直接跟一个分号,就等于执行空语句,if语句完毕,再凭空来一个else当然要出错。

#include"stdio.h"
main()
{
float score;char grade;
printf("Please input the score:");
scanf("%f",&score);
if(score>=90)
grade='A';
else if( score>=80)
grade='B';
else if (score>=70)
grade='C';
else if( score>=60)
grade='D';
else
grade='E';
printf("%f,%c\n",score,grade);
}