c语言练习题
#include"stdafx.h"voidmain(){floatscore;printf("\nPleaseenterascore");scanf("%f",&sco...
#include "stdafx.h"
void main()
{ float score;
printf("\n Please enter a score ");
scanf("%f",&score);
if(score<=0 && score>=100);
if(score>=80) printf("good\n");
else if (score>=90) printf("excellen\n");
else if (score>=70) printf("medium\n");
else if (score>=60) printf("pass\n");
else printf("not pass\n");
else printf("Data wrong!!! \n");}
有什么错误 展开
void main()
{ float score;
printf("\n Please enter a score ");
scanf("%f",&score);
if(score<=0 && score>=100);
if(score>=80) printf("good\n");
else if (score>=90) printf("excellen\n");
else if (score>=70) printf("medium\n");
else if (score>=60) printf("pass\n");
else printf("not pass\n");
else printf("Data wrong!!! \n");}
有什么错误 展开
1个回答
展开全部
#include "stdafx.h"
#include <stdio.h>//添加此头文件
void main()
{ float score;
printf("\n Please enter a score ");
scanf("%f",&score);
if(score<0 && score>100)//最后的分号去掉,<=改为<,>=改为>,0和100分都是可能的分数
printf("Data wrong!!! \n");//此句调到此处
else //添加此句
{//添加大括号
if(score>=90) printf("excellent\n");//80改为90,good改为excellent
else if (score>=80) printf("good\n");//90改为80,excellent改为good,excellent你拼写错了
else if (score>=70) printf("medium\n");
else if (score>=60) printf("pass\n");
else printf("not pass\n");
}//添加大括号
//else printf("Data wrong!!! \n");}此句调到第一个if语句之后
}
未加载必要的头文件、取值范围错误、if语句逻辑错误、单词拼写错误。一个小程序竟然把各种错误都体现出来了,还是比较少见的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询