In: Computer Science
3. Write a program using switch-case statements that accepts an integer number between 0 and 100 and, based on its value, reports its equivalent letter grade (A, B, C, D, or F).
Since the Language to be coded was not mentioned, I have written it in C
#include<stdio.h>
int main()
{
int marks;
printf("Enter marks between 0 and 100: "); //Asks for mark input
scanf("%d",&marks); //Stores in variable
switch( score / 10 ) //Runs a switch case to check the grade
{
case 10:
case 9:
printf("Grade is : A\n"); //Prints the Grade in each case
break;
case 8:
printf("Grade is: B\n");
break;
case 7:
printf("Grade is: C\n");
break;
case 6:
printf("Grade is: D\n");
break;
case 5:
printf("Grade is: E\n");
break;
default:
printf("Grade is: F\n");
break;
}
The criteria is given as
Please comment if any further explanation is needed