Histogram with pointer/arrays

Wow Im rusty at this. I have to use my second function to create a histogram of test scores.

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
#include <iostream>
#include <string>

using namespace std;

void inputArray(int*);
void calculate(int*, int*);
//void display();



int main() {
	int inputGrades[30];
	int gradeScale[101];
	int *grades;
	int *scale;
	int *students;
	students = 0;

	grades = inputGrades;
	scale = gradeScale;
	
	inputArray(grades);

	cout << grades[0] << endl;
	//cout << students << endl;
	cout << scale[10] << endl;

	system ("pause");
	return 0;
}

void inputArray(int *studentGrades) {

	int index = 0;
	
	cout << "Enter test score for student " << index + 1 << " (or -1 to quit): ";
	cin >> studentGrades[index];

	while (studentGrades[index] != -1) {
		index++;
		cout << "Enter test score for student " << index + 1 << " (or -1 to quit): ";
		cin >> studentGrades[index];
	}
}

void calculate(int *studentGrades, int *gradeScale) {
	int index2 = 0;

	for (int index = 0; index > 30, index++;) {
		index2 = studentGrades[index] + 1;
		gradeScale[index2] += 1;
	}
}

void display() {

}


I keep getting random numbers when I print an element from the scale array. Help?
Btw, I realized I hadn't put the function call in. I did that and still get random numbers.
Topic archived. No new replies allowed.