小程序_成绩

题目:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示, 60分以下的用C表示。

 

 

#include <stdio.h>

 

void main(void)
{
int score = 0;
char level = 'F';

while(1)
{
printf("Please input the score ! ");
scanf("%d",&score);

if(0>score || 100<score)
{
printf("Invaild score! ");
break;
}

level = (score>=90?'A':((score>=60)?'B':'C'));
printf("Grade is '%c' ",level);
}

}

 

/***************** 今天为了更好的明天 ******************/
原文地址:https://www.cnblogs.com/cheng-amy/p/5805733.html