输入一个百分之考试成绩通过程序判断给成绩复制分成五个级别优粮,及格不及格不及格。
时间: 2023-03-28 12:03:27 浏览: 66
您好,根据您的要求,我可以回答您的问题。以下是程序的代码:
#include <stdio.h>
int main() {
float score;
printf("请输入考试成绩:");
scanf("%f", &score);
if (score >= 90) {
printf("优秀\n");
} else if (score >= 80) {
printf("良好\n");
} else if (score >= 70) {
printf("中等\n");
} else if (score >= 60) {
printf("及格\n");
} else {
printf("不及格\n");
}
return ;
}
希望能够帮到您。
相关问题
用c语言编程由键盘任意输入一个成绩,判断其是优、良、中、及格还是不及格。
好的,以下是用 C 语言编写的代码实现:
```c
#include <stdio.h>
int main() {
float score;
printf("请输入成绩:");
scanf("%f", &score);
if (score >= 90) {
printf("成绩等级为优!\n");
} else if (score >= 80) {
printf("成绩等级为良!\n");
} else if (score >= 70) {
printf("成绩等级为中!\n");
} else if (score >= 60) {
printf("成绩等级为及格!\n");
} else {
printf("成绩等级为不及格!\n");
}
return 0;
}
```
程序首先要求用户输入一个成绩,然后通过 if-else 语句判断该成绩所属的等级,并输出相应的等级提示。如果成绩低于 60 分,则判定为不及格。
编写一个程序,使用一维数组存放10位学生的成绩,统计不及格的学生人数
好的,我可以为您解答这个问题。以下是一个用Python编写的程序,使用一维数组统计不及格学生的人数:
```python
scores = [70, 80, 55, 60, 95, 40, 75, 65, 85, 50] # 10位学生的成绩
fail_count = 0 # 统计不及格的学生人数
for score in scores:
if score < 60:
fail_count += 1 # 成绩小于60分则不及格
print("不及格的学生人数:", fail_count)
```
在这个程序中,我们首先创建了一个包含10位学生成绩的一维数组`scores`。然后,我们使用一个变量`fail_count`来统计不及格的学生人数,初始值为0。
使用`for`循环遍历数组`scores`,并对每个成绩进行判断。如果成绩小于60分,则将`fail_count`加1,表示有一个不及格的学生。
最后,输出不及格学生的人数即可。
希望这个程序能帮到您!
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)