c-practice/letter-grade.c

28 lines
666 B
C
Raw Normal View History

2020-10-20 19:30:51 -05:00
#include <stdio.h>
int main() {
int input;
scanf("%i", &input);
printf("Your input was: %i\n", input);
if ((input >= 0) && (input <= 100)) {
char letter;
if ((input/10) >= 9) {
letter = 'A';
} else if ((input/10) >= 8) {
letter = 'B';
} else if ((input/10) >= 7) {
letter = 'C';
} else if ((input/10) >= 6) {
letter = 'D';
} else {
letter = 'F';
}
printf("Your letter grade is %c\n", letter);
2020-10-20 19:30:51 -05:00
} else {
printf("ERROR: Input must be no more than 100 and no less than 0\n");
return 1;
2020-10-20 19:30:51 -05:00
}
return 0;
}