0

It provides the average grade of an student.

Assignment:

How many students are in the class ?

3

Enter five test scores for student number 1

80 90 70 90 80

The average for student number 1 is 85

Enter five test scores for student number 2

100 60 60 90 80

The average for student number 2 is 82.5

Enter five test scores for student number 3

90 70 50 70 90

The average for student number 3 is 80

**My problem is getting the average to come out as the average??

This is my only hang up, I've written this code every way till sundown and I am really

stUCK...please help, me...

Thanks, in advance.****

```
#include <iostream>
using namespace std;
void handleOneStudent (int N);
const int num_quizzes = 5;
int grade [num_quizzes];
int score, temp, pass, quiz, limit;
double grade_avg;
int main()
{
int NumberOfStudents;
cout << "How many students are in the class?" << endl;
cin >> NumberOfStudents;
cout << endl;
for (int i=1; i <= NumberOfStudents; i++)
handleOneStudent(i);
return 0;
}
// Obtain the quiz grades for each student
void handleOneStudent(int N)
{
int score [5];
cout << "Enter five test scores for student number " << N << endl;
cin >> score[0];
cin >> score[1];
cin >> score[2];
cin >> score[3];
cin >> score[4];
//Do bubble sort
limit = num_quizzes - 2;
for (pass = 1; pass <= num_quizzes - 1; ++pass)
{
for (quiz = 0; quiz <= limit; ++quiz)
if (grade [quiz] > grade [quiz + 1])
{
temp = grade[quiz];
grade[quiz] = grade[quiz + 1];
grade [quiz + 1] = temp;
}
--limit;
}
cout << "The average quiz grade is " << grade_avg << endl;
grade_avg = (grade[1] + grade[2] + grade[3] + grade[4] ) / 4.0;
int i;
for (i = 0; i < pass; ++i)
score [i];
++temp;
++grade_avg;
}
```

*Edited 6 Years Ago by WaltP*: C'mon, you don't have to CODE TAG your entire post! And this is not a code snippet