there's more. the initialization of your grades in main needs to be modified a bit...
1 2 3 4 5 6 7 8 9 10 11 12 13
|
pos = 0;
cout << "Please input a grade from 1 to 100, (or -99 to stop)" << endl;
cin >> grades[pos];
while (grades[pos] != -99)
{
cout << "enter test score number " << (pos + 1) << ":";
cin >> grades[pos];
}
numberOfGrades = grades[pos]; // Fill blank with appropriate identifier
|
I want you to think:
-> what values does pos have to take during this procedure?
-> what values does pos actually take during this procedure?
-> should you stop the loop only when -99 is entered or also when the number of entries has reached the capacity of the array?
-> let's say that the user has given 10 entries. what would be better? to set the remaining (unused) elements of the array to some value that doesn't affect the output of the find<Average/Lowest/Highest> functions OR to store the number of entries somewhere so that these functions know what data they should operate on? (It seems to me that you are trying to do something like the latter with numberOfGrades but neither do you set the value of this variable correctly nor do you declare it in a scope that would make it available to your find functions)
EDIT: oops, forget the last one... just saw that you pass it as a parameter in you functions hahaha. Still you don't set its value correctly...
EDIT2: hmmm... you pass numberOfGrades in findAverage but not in the other two... Why is size necessary? And what value do you assign to it before you pass it in your functions?
1 2 3
|
avgOfGrades = findAverage(grades, numberOfGrades);
highestGrade = findHighest(grades, size);
lowestGrade = findLowest(grades, size);
|
Also you use the parameter correctly only in your first function (findAverage). My guess is that that's how all of your functions worked initially but because the results weren't what you expected to be (due to the bad initialization of the array) you modified the code in your functions trying to fix a problem located somewhere else... (that is in the initialization of the array)