[ Must utilize <stdio.h> , printf, scanf statements ] Write a program that promp
ID: 3531674 • Letter: #
Question
[ Must utilize <stdio.h> , printf, scanf statements ]
Write a program that prompts for and accepts input of test grades that are integers between 0 and 100.
For each numerical test grade, the program should display a corresponding letter grade based on the following criteria:
If grade is between 90 and 100 inclusive, display an 'A'.
If grade is between 80 and 89 inclusive, display a 'B'.
If 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'
Program should continue to read and classify the test grades until the user enters -1 as a sentinel value.
Explanation / Answer
There were small errors in above program... here is complete correct code... please rate me only with five stars
/*
Write a program that prompts for and accepts input of test grades that are integers between 0 and 100.
For each numerical test grade, the program should display a corresponding letter grade based on the following criteria:
If grade is between 90 and 100 inclusive, display an 'A'.
If grade is between 80 and 89 inclusive, display a 'B'.
If 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'
Program should continue to read and classify the test grades until the user enters -1 as a sentinel value.
*/
#include <stdio.h>
int main(){
int m;
char ch;
printf("Enter Test grade Integer:");
scanf("%d",&m);
while(m!=-1){
if(m>=90 && m<=100)
ch='A';
else if(m>=80)
ch='B';
else if(m>=65)
ch='C';
else if(m>=50)
ch='D';
else
ch='F';
printf("Letter grade: %c ",ch);
printf("Enter Test grade Integer:");
scanf("%d",&m);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.