Question: How to fix the code below so it will run the error message: [Error] invalid operands of types 'const char [3]' and 'int' to binary
How to fix the code below so it will run
the error message: [Error] invalid operands of types 'const char [3]' and 'int' to binary 'operator&'
in the C language Write a program that assigns test score grades. The program's input should be a series of test scores of type int. Have the program read each score and print either the corresponding grade or an appropriate error message. The program is to continue until end-of-file. If invalid character data is entered, you will need to flush the invalid characters so that test scores can continue to be entered until end-of-file.
#include
int main() { int score;
printf("Enter your score between 0 to 10 "); scanf("%d", &score); while((r=scanf("%i" & score))!=EOF) { if(r==0) { printf("invalid char"); while(getchar()!=' '); } else switch(score) { case 10 : case 9 : /* score between 9-10 */ printf("Your Grade : A " ); break; case 8 : /* score 8 */ printf("Your Grade : B " ); break; case 7 : /* score 7 */ printf("Your Grade : C " ); break; case 6 : /* score 6 */ printf("Your Grade : D " ); break; case 5 : case 4 : case 3 : case 2 : case 1 : case 0 : /* score between 0-5*/ printf("Your Grade : F " ); break;
default : /* score less than 0 */ if(score<0) printf("Negative Number " ); if(score>10) printf("Value greater than 10 " ); if(score >= 'a' && score <= 'z' || score >= 'A' && score <= 'Z') printf("A character value " ); } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
