• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
November 22, 2022 |10.0K Views

C Program to Calculate Grade of Student

  Share  2 Likes
Description
Discussion

In this video, we will write a C Program to Calculate the Grade of Students. So the task is in given integer array marks, which comprises marks scored by a student( out of 100) in different subjects and assign a grade to the student. The grade is found out by taking the percentage of the marks scored by the student.

The grade is calculated using the formula = Total number of marks scored/ Maximum number of all marks

Examples:
Input 
Marks = { 55, 65, 46, 58, 78, 65}
Output:  Grade C

Input marks = { 95, 88, 98, 98, 92, 96}
Output: Grade A

Basic Algorithm: 

  1. First Initialize a variable to sum all the marks scored by the student, total to 0.
  2. Then Initialize a variable to store the grade of the student, grade to ‘ F ’.
  3. Now, we iterate through the marks array and find the total marks scored by the student.
  4. We apply the formula described above to calculate the percentage.
  5. We also make nested if else or Switch case statements to construct to assign proper grades to the student.