C语言练习题,用if-else语句编程根据输入的百分制成绩score,转换成相应的五分制成绩grade后输出

用if-else语句编程根据输入的百分制成绩score,转换成相应的五分制成绩grade后输出。已知转换标准为:

0-59    E

60-69   D 

70-79   C 

80-89   B 

90-100  A

**输入格式要求:"%d" 提示信息:"Please enter score:"
**输出格式要求:"Input error!\n" "%d——A\n"
程序运行示例1如下:
Please enter score:15
15——E
程序运行示例2如下:
Please enter score:85
85—B

#include<stdio.h>
int main()
{
 int score;
 char grade;
 printf("Please enter score:");
 scanf("%d",&score);
 if (score>=90&&score<=100)
  printf("%d——A\n",score);
 else if (score>=80&&score<=89) 
  printf("%d——B\n",score);
 else if(score>=70&&score<=79) 
  printf("%d——C\n",score);
 else if(score>=60&&score<=69) 
  printf("%d——D\n",score);
 else if(score>=0&&score<=59) 
  printf("%d——E\n",score);
 return 0;
}

运行结果

 

  • 6
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杪商柒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值