So this program is supposed to read an unknown number of values (max 30) and then attribute the grades entered into an array to track how many of each grade there are.
Im having issues with how I should pass these pointers. Rules are all parameters have to be pointers, but no matter how I try I cant get it to work.
I was going to replace the index in the calculate function with the values pointer. I just want it to be able to pass it properly before I change it.
#include <iostream>
usingnamespace std;
void inputArray(int, int);
void calculate(int, int, int);
int main() {
int studentGrades[30];
int gradeScale[101];
int values = 0;
inputArray(studentGrades, values);
calculate(studentGrades, gradeScale, values);
system ("pause");
return 0;
}
void inputArray(int *studentGrades, int *values) {
cout << "Enter test score for student " << *values + 1 << " (or -1 to quit): ";
cin >> studentGrades[*values];
while (studentGrades[*values] != -1) {
values++;
cout << "Enter test score for student " << *values + 1 << " (or -1 to quit): ";
cin >> studentGrades[*values];
}
}
void calculate(int *studentGrades, int *gradeScale, int *values) {
for (int index = 0; index < 101; index++)
gradeScale[index] = 0;
for (int index = 0; index < *values; index++) { //index needs to be a pointer?
int score = studentGrades[index]; //assign studentGrades[index] value to the corresponding vale in the gradeScale 1;
gradeScale[score] += 1;
}
}