Home » C Programs » C Program to Calculate Percentage of 5 Subjects

# C Program to Calculate Percentage of 5 Subjects

Basic c program to calculate percentage of 5 subjects. Using this program we can execute the c program to calculate percentage of 5 subjects for beginners.

## Percentage Definition

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. How to calculate percentage in c for freshers to understand the concept of switch statement. This is how to find the percentage of two numbers in java.

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.

## 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.

## Nested if Statement in How to Calculate Percentage

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. This is sample c program to calculate percentage of 5 subjects.

## .2f in C Program

The “.2” tells your “print” to print only the first two digits after the point. “print” treats the percent as a special character you must add so it knows that when you type “f,” the number result that will be printed is a floating point type, and the “.2” tells your “print” to print only the first two digits after the point.

## C Program to Calculate Percentage of 5 Subjects

``````#include <stdio.h>
int main()
{
float sub_1, sub_2, sub_3, sub_4, sub_5;
float final, avg, perc;
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)
else if (avg >= 80 && avg < 90)
else if (avg >= 70 && avg < 80)
else if (avg >= 60 && avg < 70)
else
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);
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%