In this tutorial you will learn about the C Program to find Student Grade and its application with practical example.
C Program to find Student Grade
In this tutorial, we will learn to create a C program that will find the Student Grade in C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional Statements in c programming.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declare the variables for the program. 2. Taking the input numbers of five subjects. 3. Calculating the total. 4. Calculating the percentage. 5. Print the total, percentage and the grade. 6. End the program. |
Program to find Student Grade.
In this program, we will first take the marks of five subjects from the user. After taking the input, we will add all the marks and divide them by “5″ to get the percentage of the marks. Then we will print the grade of the students using the conditional statements.
Below is an example of the total, percentage, and grade.
1 2 3 4 |
For Example :- total = 50+50+50+50+50 percentage = 50.00 grade = E |
With the help of this program, we can find the grade of the student.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
//Including the required header files for the program. #include <stdio.h> int main() { //Declaring the required variable for the program. int EN, CH, CM, PH, MT; //EN = it will hold an integer value for the input number. //CH = it will hold an integer value for the input number. //CM = it will hold an integer value for the input number. //PH = it will hold an integer value for the input number. //MT = it will hold an integer value for the input number. float TOT, PER; //Taking the input MARKS from the user for the program. printf(" Please Enter the Five Subjects Marks : \n"); //Scanning the input number from the user. scanf("%d%d%d%d%d", &EN, &CH, &CM, &PH, &MT); TOT = EN + CH + CM + PH + MT; PER = (TOT / 500) * 100; printf(" Total Marks = %.2f\n", TOT); printf(" Marks Percentage = %.2f", PER); if(PER >= 90) { //Printing the grade A. printf("\n Grade A"); } else if(PER >= 80) { //Printing the grade B. printf("\n Grade B"); } else if(PER >= 70) { //Printing the grade C. printf("\n Grade C"); } else if(PER >= 60) { //Printing the grade D. printf("\n Grade D"); } else if(PER >= 40) { //Printing the grade E. printf("\n Grade E"); } else { printf("\n Fail"); } return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- EN, CH, CM, PH, MT = it will hold the input value of the numbers.
- TOT = it will hold the float value for the total marks.
- PER = it will hold the float value for the percentage.
Taking the input marks of the five subjects.
In this section of the code of the program, we will calculate the total of the marks and the percentage.
Printing the grade of the student according to the percentage.