Gradebook help! (array using for loop)

I have a grade book assignment that I can't for the life of me figure out. I am relatively new at C++ so I'm sure it's not difficult, but I still need help. Here is my assignment:

"Create a grade book program as follows:
1. Ask user to give total number of students;
2. Ask user to enter numerical grade for each student;
3. Print to screen the average, highest and lowest grade;"

The output screen should say:

"How many students in the class?"

Say I enter 5, then it should ask me for the 5 test scores, saying "Enter student 1 numerical grade (0-100):"
and then student 2, student 3, etc.

After I enter the scores, I need the average, the highest score, and the lowest score.

I was able to get up to asking for the test scores, but am struggling with an array that gives me the average and the highest and lowest score. This is more code so far:

1 #include <iostream>
2 #include <cstdlib>
3 using namespace std;

4 int main()
5{
6 int x;
7 int num;
8 int i;
9 int avg;
10 int num;
11 float input, sum=0, avg;


12 cout << "How many people in the class? " ;
13 cin >> x;


14 for(int i = 1; i <= num; i++)
15 {
16 cout << "Enter student " << i+1 << " numerical grade (0-100): " << endl;
17 cin >> num;
18 }
19 {
20 cin >> input;
21 sum += num;
22 }
23
avg = num / x;
24 cout << "The average grade is " << avg << endl;
25 return 0;
26 }


PLEASE HELP!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75


#include <iostream>
using namespace std;

double get_average(double a[],const int the_size);
double get_highest(double a[],const int the_size);
double get_lowest(double a[],const int the_size);

int main(){


	char dummy;
	unsigned int total_students;
	double grades[100], temp_grade;

	cout<<"Enter total students: ";
	cin>>total_students;
	
	cout<<endl;
	for(int i=0;i<total_students;i++){
		
		cout<<"Enter grade: ";
		cin>>temp_grade;
		grades[i]=temp_grade;
	
	}

	double average=get_average(grades,total_students);
	double lowest=get_lowest(grades,total_students);
	double highest=get_highest(grades,total_students);

	cout<<"\nAverage: "<<average<<endl;
	cout<<"Lowest: "<<lowest<<endl;
	cout<<"Highest: "<<highest<<endl;

	cin>>dummy;

	return 0;
}
double get_highest(double a[],const int the_size){
	double highest=a[0];
	for(int i=1;i<the_size;i++){
		
		if(highest>a[i])
			highest=a[i];
	
	}
	return highest;

}
double get_lowest(double a[],const int the_size){
	double lowest=a[0];
	for(int i=1;i<the_size;i++){
		
		if(lowest<a[i])
			lowest=a[i];
	
	}
	return lowest;

}
double get_average(double a[],const int the_size){

	double total=0;

	for(int i=0;i<the_size;i++){
		
		total=total+a[i];
	
	}
	return (total/the_size);
}

Topic archived. No new replies allowed.