letter-grade.c: Change printf to %li instead of %i and move return 0; inside if statement
This commit is contained in:
parent
1bd69ff2e4
commit
0a4002e05f
@ -2,12 +2,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
printf("Please enter a whole number percentage (0-100): ");
|
||||||
char inputText[4];
|
char inputText[4];
|
||||||
fgets(inputText, 4, stdin);
|
fgets(inputText, 4, stdin);
|
||||||
printf("inputText: %s\n", inputText);
|
printf("inputText: %s\n", inputText);
|
||||||
long int input;
|
long int input;
|
||||||
input = strtol(inputText, NULL, 0);
|
input = strtol(inputText, NULL, 0);
|
||||||
printf("input: %i\n", input);
|
printf("input: %li\n", input);
|
||||||
|
|
||||||
if ((input >= 0) && (input <= 100)) {
|
if ((input >= 0) && (input <= 100)) {
|
||||||
char letter;
|
char letter;
|
||||||
@ -33,10 +34,9 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Your letter grade is %c\n", letter);
|
printf("Your letter grade is %c\n", letter);
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
printf("ERROR: Input must be no more than 100 and no less than 0\n");
|
printf("ERROR: Input must be no more than 100 and no less than 0\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user