BUPT-homework/semester1/pset4/3-grade.c

32 lines
541 B
C
Raw Permalink Normal View History

2021-10-19 22:58:02 +08:00
#include <stdio.h>
void get_score(int s);
int main(void) {
// Initialize variables and get input from stdin
int score;
scanf("%d", &score);
get_score(score);
return 0;
}
void get_score(int s) {
if (s > 100) {
printf("The score is out of range!\n");
} else if (s >= 90) {
printf("A\n");
} else if (s >= 80) {
printf("B\n");
} else if (s >= 70) {
printf("C\n");
} else if (s >= 60) {
printf("D\n");
} else if (s >= 0) {
printf("E\n");
} else {
printf("The score is out of range!\n");
}
}