# How to Calculate Aggregate and Percentage Marks from Subject Scores in C Programming

## If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100

Introduction

In the realm of education, evaluating a student’s performance is crucial. Often, educators and students need to determine the aggregate and percentage marks obtained in different subjects to gauge overall academic progress accurately. This article will guide you through the process of calculating the aggregate and percentage marks of a student based on their scores in five different subjects. We will assume that the maximum marks that can be obtained in each subject are 100 and that the calculations will be performed in the C programming language.

Understanding the Problem

Before diving into the implementation, let’s clarify the problem. We are given the marks obtained by a student in five different subjects, and our task is to find both the aggregate marks and the percentage marks achieved. The aggregate marks represent the total of all subject scores, and the percentage marks are the average of those scores calculated as a percentage out of the total marks possible (i.e., 100 marks per subject).

Implementation in C

Let’s start by writing a C program to solve the problem step by step:

#include <stdio.h>

int main() {
// Declare variables to store subject scores and aggregate marks
int subject1, subject2, subject3, subject4, subject5;
int aggregateMarks;
float percentageMarks;

// Input subject scores from the keyboard
printf("Enter the marks obtained in Subject 1: ");
scanf("%d", &subject1);

printf("Enter the marks obtained in Subject 2: ");
scanf("%d", &subject2);

printf("Enter the marks obtained in Subject 3: ");
scanf("%d", &subject3);

printf("Enter the marks obtained in Subject 4: ");
scanf("%d", &subject4);

printf("Enter the marks obtained in Subject 5: ");
scanf("%d", &subject5);

// Calculate the aggregate marks
aggregateMarks = subject1 + subject2 + subject3 + subject4 + subject5;

// Calculate the percentage marks
percentageMarks = (float)aggregateMarks / 500 * 100;

// Output the results
printf("\nAggregate Marks: %d\n", aggregateMarks);
printf("Percentage Marks: %.2f%%\n", percentageMarks);

return 0;
}


Explanation

1. We start by including the necessary header files for input/output operations (stdio.h).
2. Next, we declare the variables required for storing subject scores, aggregate marks, and percentage marks.
3. The program prompts the user to input the marks obtained in each subject one by one using the scanf() function.
4. The aggregate marks are calculated by adding the scores obtained in all five subjects.
5. To obtain the percentage marks, we divide the aggregate marks by the maximum marks possible (500, as each subject has a maximum of 100 marks) and then multiply by 100.
6. Finally, the program displays the calculated aggregate marks and percentage marks using the printf() function.

Conclusion

In conclusion, accurately evaluating a student’s performance is vital for their academic growth. By using the C programming language, we can efficiently calculate the aggregate marks and percentage marks obtained by a student in five different subjects. This knowledge empowers educators and students to make informed decisions about their academic progress and identify areas for improvement. With this simple C program, you can quickly compute the aggregate and percentage marks, enhancing the educational assessment process.