Write the select case program o display the grades of the class
Case A - amazing
Case B - Good
Case c average
case else - fail
Answers
Answer:
Here, we will write a C program to find the grade of a student using switch case statements. The below table shows the grading system.
Score in subjectGrade>=90A80-89B70-79C60-69D50-59E<50F
Prerequisites for finding grade of a student using switch case statements:-
Explanation:
program to find grade of a student using switch case statement
#include<stdio.h> int main() { int score; printf("Enter score( 0-100 ): "); scanf("%d", &score); switch( score / 10 ) { case 10: case 9: printf("Grade: A"); break; case 8: printf("Grade: B"); break; case 7: printf("Grade: C"); break; case 6: printf("Grade: D"); break; case 5: printf("Grade: E"); break; default: printf("Grade: F"); break; } return 0; }
Output for the test-case-1:-
Enter score( 0-100 ): 100
Grade: A