WAP to Calculate Percentage and Grades in C

Writing a program that can efficiently calculate the percentages and assign grades based on predefine criteria is a fundamental task. In this article we will see how to develop a simple C program that accepts marks in five subjects, Calculates the overall percentage, and prints grades according to specified criteria.

Problem Statement- WAP that accepts marks of five subjects and finds percentage and prints grades according to the following criteria:

  • Between 90-100%—–Print ‘A’
  • 80-90%—————–Print ‘B’
  • 60-80%—————–Print ‘C
  • ’Below 60%————-Print ‘D’

C Program to Calculate Percentage and Grades

Output

C Program to Calculate Percentage and Grades

Explanation of the Above C Program

  • The above C program asks the user to enter the subject of each mark and stores it in an array subject[5].
  • The total marks are calculated by summing the marks of all 5 subjects.
  • Percentage is calculated by dividing the total marks by 5(total number of subjects).
  • In the end by using the conditional statement if else the C program determines the grade based on the given criteria and prints the corresponding grade.

Happy Coding

See Also

2 thoughts on “WAP to Calculate Percentage and Grades in C”

Leave a Comment