please use printf anf scanf library functions and for control statements use if,
ID: 3652935 • Letter: P
Question
please use printf anf scanf library functions and for control statements use if, if else, while , for. this 4 statements any of them. Okay I guess picture did not uploaded correctly, here is the question A C program that prompts for and accepts input of test grades that are integers between o and 100. For each numericals test grade, your program should display a corresponding letter grade based on the following rules: if the grade is between 90 and 100 inclusive, display an "A" if the grade is between 90 and 100 inclusive, display an 'A' if the grade is between 80 and 89 inclusive, display a 'B' if the grade is between 65 and 79 inclusive, display a 'C' if the grade is between 50 and 64 inclusive, display a 'D' if the grade is less than 50, display an 'F' the program should continue to read and classify the test grades until the user enters -1 as a sentinel value.Explanation / Answer
please rate - thanks
hope it's okay that I include invalid grade message. if not message me
#include <stdio.h>
int main()
{int grade;
printf("Enter a grade(-1 to exit): ");
scanf("%d",&grade);
while(grade!=-1)
{if(grade>100)
printf("Invalid grade ");
else if(grade>=90)
printf("That's an A ");
else if(grade>=80)
printf("That's a B ");
else if(grade>=70)
printf("That's a C ");
else if(grade>=60)
printf("That's a D ");
else if(grade >= 0)
printf("That's an F ");
else
printf("Invalid grade ");
printf("Enter a grade(-1 to exit): ");
scanf("%d",&grade);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.