How to Calculate Percentage of 5 Subjects

C Program to Calculate Percentage of 5 Subjects. In this program we can learn how to calculate percentage of marks of 5 subjects in c program. Using this c program you can calculate different five subjects in c. 

#include <stdio.h>
int main()
{
float sub_1, sub_2, sub_3, sub_4, sub_5;
float final, avg, perc;
char grade;
printf("Enter the marks of five subs\n");
scanf("%f%f%f%f%f", &sub_1, &sub_2, &sub_3, &sub_4, &sub_5);
final = sub_1 + sub_2 + sub_3 + sub_4 + sub_5;
avg = final / 5.0;
perc = (final / 500.0) * 100;
if (avg >= 90)
grade = 'A';
else if (avg >= 80 && avg < 90)
grade = 'B';
else if (avg >= 70 && avg < 80)
grade = 'C';
else if (avg >= 60 && avg < 70)
grade = 'D';
else
grade = 'E';
printf("\nThe final marks is: \t%.2f / 500.00\n", final);
printf("\nThe avg marks is:\t%.2f\n", avg);
printf("\nThe perc is: \t%.2f%%\n", perc);
printf("\nThe Grade is: \t'%c'\n", grade);
return 0;
}

 

Output:

Enter the marks of five subs
45
6
76
87
34

The final marks is: 248.00 / 500.00

The avg marks is: 49.60

The perc is: 49.60%

The Grade is: ‘E’

C Program to Calculate Percentage of 5 Subjects Using Switch Statement

The number of values below ‘x’ divided by the total number of values yields the percentile. Percentile Formula is a formula that calculates the percentage of a population. Percentile (P) = (Number of Values Below “x” / Total Number of Values) / 100 is the Percentile Formula. C Program to Calculate Percentage of 5 Subjects for Freshers to understand the concept of switch statement.

What is Grading System in Education

In general, the grading system is the process by which educators evaluate students’ performance in exams on standard particular scales that are entirely based on points and consist of grades like A-F or ranges like 1-10; generally, letters and numbers are used to describe student grades.

What is Floating Number in C

The term “floating point” is abbreviated as “float.” It’s a built-in data type that’s used to define numeric values with floating decimal points, according to the definition. Float is a data type that is recognised by C, C++, C#, and many other programming languages.

What is Nested if Statement in C Program to Calculate Percentage of 5 Subjects

In C, a nested if statement is one that is the target of another if statement. An if statement inside another if statement is referred to as nested if statements. Yes, both C and C++ allow us to nest if statements within if statements, allowing us to put one if statement inside another.

Similar Programs