#include<stdio.h>
int main()
{
int score;
scanf("%d",&score);
if(100>=score>89)
printf("A");
else if(89>=score>=80)
printf("B");
else if(79>=score>=70)
printf("C");
else if(69>=score>=60)
printf("D");
else if(60>score)
printf("F");
}
And
#include<stdio.h>
int main()
{
int score;
scanf("%d",&score);
if(90<=score<=100)
printf("A");
else if(80<=score<=89)
printf("B");
else if(70<=score<=79)
printf("C");
else if(60<=score<=69)
printf("D");
else if(score<60)
printf("F");
}
The difference is only an inequality sign, so why can't it be implemented? Do I have to do small number <x<large number
?
In C language, if (100>=score>89)
should not be written like this, but if (100>=score&&score>89)
.
&&&
is a logic-and operator, and the whole is true when the left one is true and the right one is true.
There's no one who's good from the beginning. Keep up the good work and good luck.
#include<stdio.h>
int main()
{
int score;
scanf("%d",&score);
if(100>=score && score>89)
printf("A");
else if(89>=score && score>=80)
printf("B");
else if(79>=score && score>=70)
printf("C");
else if(69>=score && score>=60)
printf("D");
else if(60>score)
printf("F");
}
© 2024 OneMinuteCode. All rights reserved.