C program to find the grade of marks of a student using switch case statement
Problem Description
This program take input as your number then show your grade.
So first divide the mark by 10 so we can get a reminder and as you can see in the program we use case 4 to case 10. So if the remainder is between 4 to 10 our case perform the particular grade operation and display the result See the Step By Step Example for each case may be in this grade problem.
Explanation
Case 1:- If the user is Over smart then there is a condition that if the mark given by the user is greater than 100 then our program display the Message "Don't Be Smart Enter your Marks Between Limit" or else perform the Else part.
Enter the Mark:- 1000
Output:- Don't Be Smart Enter your Marks Between Limit.
Case 2:- If the user is entering the marks between the 0 to 100 and then particular grade portion will be executed and display the output in Console screen.
Enter the Mark:- 95
Output:-Your Grade Is: A or Excellent
This operation performs same for Grade B, C, D.
Case 3:- If Enter marks are not fulfilled the cases requirement than the program will perform the default case.
Enter the Mark:-25
Output:-You Grade Is: F or Fail
Program code:-
main()
{
int m, i;
printf("\n Enter any number: ");
scanf("%d", &m);
i = m%10;
switch(i)
{
case 10:
case 9:
printf("O");
break;
case 8:
printf("E");
break;
case 7:
printf("A");
break;
case 6:
printf("B");
break;
case 5:
printf("C");
break;
case 4:
printf("D");
break;
default:
printf("F");
}
}
Output of this program:-
Comments
Post a Comment
please subscribe my blog and let me suggest how I improve this site