letter-grade.c: Check if input is between 0 and 100 (inclusive)

This commit is contained in:
BBaoVanC 2020-10-20 19:56:12 -05:00
parent bd022c5f22
commit 2beb50bb25
No known key found for this signature in database
GPG Key ID: 6D74C8B0E7D791C2
1 changed files with 16 additions and 11 deletions

View File

@ -5,6 +5,7 @@ int main() {
scanf("%i", &input);
printf("Your input was: %i\n", input);
if ((input >= 0) && (input <= 100)) {
char letter;
if ((input/10) >= 9) {
letter = 'A';
@ -17,7 +18,11 @@ int main() {
} else {
letter = 'F';
}
printf("Your letter grade is %c\n", letter);
} else {
printf("ERROR: Input must be no more than 100 and no less than 0\n");
return 1;
}
return 0;
}