Q:

C Program to Find Grade of a Student Using Switch Case

belongs to collection: Switch Case Basic C Programs List

0

Write a C Program to Find Grade of a Student Using Switch Case, The user needs to enter the subject number and the program must return the Grade of the subject based on the number. If a student enters the number between 90 to 100 then our program must return the Grade A or Excellent, similarly for other ranges numbers. To get the help I have a Number to grade conversion table this may help you to find the proper logic and roadmap for our program to Calculate Grade Using Switch Statement in C.

 
Logic: Calculate Grade Using Switch Statement in C
Logic is very simple to Calculate Grade Using Switch Statement in C. Taking input from the user(Input should be between range given 0 to 100 Else program play with you), as we know that grading system so divides the Mark by 10 and put the case condition in program See the below Explanation Step by step for better understanding.
 

Number to Grade Conversion Table
Below is the number to Grade Conversion Table helps us to implements logic for C Program to Find Grade of a Student Using Switch Case. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>

int main()
{
   int marks;
   /*C Program to Find Grade of a Student Using Switch Case*/
   
   printf("\n-----------------------------------");
   printf("\nEnter The Marks Between 0 To 100:");
   
   printf("\nEnter The Mark: ");
   scanf("%d", &marks);
   
   if(marks>100)
   {
    /* Marks greater than 100 */
    printf("\nDon't Be Smart Enter your Marks Between Limit\n");
   }
   else
   {
   switch(marks/10)
   {
       case 10 :
       case 9 :
           /* Marks between 90-100 */
           printf("\n Your Grade is: A");
           break;
       case 8 :
            /* Marks between 80-89 */
           printf("\n Your Grade is: B" );
           break;
       case 7 :
           /* Marks between 70-79 */
           printf("\n Your Grade is: C" );
           break;
       case 6 :
           /* Marks between 60-69 */
           printf("\n Your Grade is: D" );
           break;
       case 5 :
            /* Marks between 50-59 */
           printf("\n Your Grade is: E" );
           break;
       case 4 :
           /* Marks between 40-59 */
           printf("\n Your Grade is: E--");
           break;
       default :
           /* Marks less than 40 */
           printf("\n You Grade is: F or Fail\n");
   }
 }

   getch();
   return 0;
}

 

Output:

Enter The Marks Between 0 To 100:

Enter The Mark: 95

 Your Grade is: A

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program For Find Radius, Circumference and Volum... >>
<< C Program For Calculator Using Switch Case...