So, im very new to C and I'm trying to teach myself the language.
My buddy has been giving me these little programs to make and for the life of me I cannot get this to work. All I have to do is write a code that will ask for the user to input a grade of A B C D or E, of the user says A, B, or C then print pass, if the user says D or E print fail. Set the code to ask for the a grade 10 times. The code i have is:
It compiles fine, but when i run the program i get:Code:#include<stdio.h> int main () { int i=0; for(i=0;i<10;i++) { char c; printf("Please enter grade\n"); scanf("%c", &c); if(c == 'A' || c=='B' || c=='C') printf("Pass\n"); if(c=='D' || c=='E') printf("Fail\n"); } return 0; }
Please enter grade
A
Pass
Please enter grade
Please enter grade
B
Pass
Please enter grade
Please enter grade
C
Pass
Please enter grade
Please enter grade
D
Fail
Please enter grade
Please enter grade
E
Fail
Please enter grade