0% found this document useful (0 votes)
6 views3 pages

Grade Calculation Program in C++

The document contains a C++ program that calculates the average, maximum, and minimum grades of students. It prompts the user to enter the number of students and their respective grades, then computes and displays the results. The program utilizes dynamic memory allocation for storing grades and includes functions for average, maximum, and minimum calculations.

Uploaded by

mntsr80awdail
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Grade Calculation Program in C++

The document contains a C++ program that calculates the average, maximum, and minimum grades of students. It prompts the user to enter the number of students and their respective grades, then computes and displays the results. The program utilizes dynamic memory allocation for storing grades and includes functions for average, maximum, and minimum calculations.

Uploaded by

mntsr80awdail
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<iostream.

h>
#include<conio.h>

float calculateAverage(int* grades, int n) {


float sum = 0;
for (int i = 0; i < n; ++i) {
sum += *(grades + i);
}
return sum / n;
}

int findMaxGrade(int* grades, int n) {


int max = *grades;
for (int i = 1; i < n; ++i) {
if (*(grades + i) > max) {
max = *(grades + i);
}
}
return max;
}
int findMinGrade(int* grades, int n) {
int min = *grades;
for (int i = 1; i < n; ++i) {
if (*(grades + i) < min) {
min = *(grades + i);
}
}
return min;
}

main() {
int n;

cout << "Enter the number of students: ";


cin >> n;

int* grades = new int[n];

for (int i = 0; i < n; ++i) {


cout << "Enter grade for student " << i + 1 << ": ";
cin >> *(grades + i);
}

cout << "Average grade: " << calculateAverage(grades, n) <<


endl;
cout << "Maximum grade: " << findMaxGrade(grades, n) <<
endl;
cout << "Minimum grade: " << findMinGrade(grades, n) <<
endl;

delete[] grades;

getch();
}

You might also like