C Program to calculate sum of 5 subjects, calculate percentage and grade
###### Posted by Samath
Last Updated: January 02, 2017

Write a C program that will accept five subjects from the user; calculate sum of the 5 subjects, calculate percentage and grade according to following conditions:

Percentage >= 90% : Grade A
Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F

Code:

```#include<stdio.h>

int main() {
int s1, s2, s3, s4, s5, sum, total = 500;
float per;

printf("\nEnter grades of the 5 subjects: ");
scanf("%d %d %d %d %d", &s1, &s2, &s3, &s4, &s5);

sum = s1 + s2 + s3 + s4 + s5;

per = (sum * 100) / total;

printf("Percentage: %.2f\n", per);

if(per >= 90)
{
}
else if(per >= 80)
{
}
else if(per >= 70)
{
}
else if(per >= 60)
{
}
else if(per >= 40)
{
}
else
{
}
return (0);
}```

###### C++ program that accepts a grade from a user and outputs a letter grade
Samath | Nov 04, 2014
###### Write a C++ program that display the percentage of persons that have passed the class
Samath | Nov 02, 2014
###### Sum of two values in C
Samath | Nov 09, 2014
###### C Program to find sum of two numbers
Samath | Jan 02, 2017
###### C++ Calculate the sum from 1 to 100
Samath | Jan 05, 2017
###### Java program that compute the average test score for a student and assign the appropriate letter grade
Samath | Jan 17, 2024
###### Write a C++ program that find the sum of all even numbers between 1 and 30 excluding 6, 8, 24 and 28
Samath | Nov 02, 2014
###### Sum of the first 30 squares in C
Samath | Dec 21, 2014
###### Java program that uses a loop to compute the sum of all odd digits of an input. (For example, if the input is 32677, the sum would be 3 + 7 + 7 = 17.)
Samath | Apr 03, 2022
###### Recursive function that find the sum of digits in a integer using C++
Samath | Dec 24, 2014
###### C program to find sum of elements of the array
Samath | Jan 02, 2017
###### Java program that prints the sum of the first ten positive integers
Samath | Jan 08, 2021
###### Java program that uses a loop to compute the sum of all even numbers between 2 and 100 (inclusive)
Samath | Apr 03, 2022
###### C program that prompts the user for a positive integer and then computes the sum of all the digits of the number
Samath | May 04, 2016