Hi!
For the sake of exercising, I wanted to create a simple cose which shall display a certain grade, based on the user-input score.
But no matter which score I would let the user put in, it always would display "Grade C".
Can you find my mistake?
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
int score;
char grade1 = 'A';
char grade2 = 'B';
char grade3 = 'C';
char grade4 = 'F';
printf("What was the student's score? Please enter the score: ");
scanf("%c", &score);
if(score >= 90){
printf("The student's grade is %c", grade1);
}else if(score >=70 && score < 90){
printf("The student's grade is %c", grade2);
}else if(score >= 50 && score < 70 ){
printf("The student's grade is %c", grade3);
}else{
printf("The student's grade is %c and he has failed the test.", grade4);
}
return 0;
}
Im grateful for any help.^^
regards,
Placebo