Question: This lab will require you to develop a switch statement that will return the numerical grade for an integer value based on the following grade
This lab will require you to develop a switch statement that will return the numerical grade for an integer value based on the following grade scale: 100 - 90 = 'A', 89 - 80 = 'B', 79 - 70 = 'C', 69 - 60 = 'D' and anything below a 60 is an 'F'.
Recall that division of integers results in an integer value when used in an expression. 100 / 10 = 10 and 95 / 10 = 9 and 63 /10 = 6.
The program will prompt the user for a numerical grade value between 0 and 100. You must construct a switch statement that will set the grade variable = to the character that correlates to the grade of the score using the scale above.
A program shell has been provided. You should make use of the break statement. NOTE: An 'A' will result for both a 10 and a 9 value.
#include
int main(void) { int numGradeIn = 0; int numGrade = 0; char ltrGrade = ' '; printf("Enter in a numerical grade between 0 and 100: "); scanf("%d", &numGradeIn); printf(" "); numGrade = numGradeIn / 10; /* edit your code here. */ switch(numGrade) { case: case: case: case: case: default: ltrGrade = 'F'; }//end switch printf("The letter grade for %d is %c ", numGradeIn, ltrGrade);
return 0; }
In C programming
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
