### Question about test scores program w/ pointers

closed account (3UMLy60M)
Hello all,

I have created a program that allows for a user-defined number of test scores as input. After the user enters these scores, the program calculates the average test score. Here is my code:

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172`` ``````#include #include using namespace std; // Function prototypes double getAverage(double*, int); int main() { // Variable declarations double *testScores; // Dynamically allocate an array of test scores double average; // Hold the average test score int numTests; // Number of test scores int count; // Counter variable // Get the number of tests cout << "How many tests do you wish to process? "; cin >> numTests; // Verify input is not a negative number while (numTests <= 0) { // Get input again. cout << "Please enter a positive number: "; cin >> numTests; } // Dynamically allocate an array large enough to hold the test scores testScores = new double[numTests]; // Get the specified number of test scores cout << "Enter the test scores below.\n"; for (count = 0; count < numTests; count++) { cout << "Test " << (count + 1) << ": "; cin >> *(testScores + count); // Verify input is not a negative number while (*(testScores + count) < 0) { // Get input again. cout << "Please enter a valid test score.\n"; cin >> *(testScores + count); } } // Calculate the average test score average = getAverage(testScores, numTests); // Display the results. cout << fixed << showpoint << setprecision(2); cout << endl; cout << "The average of those scores is: " << average << endl; // Free dynamically allocated memory delete [] testScores; testScores = 0; // Make testScores point to null return 0; } //function getAverage - calculates the average of the test scores double getAverage(double* scores, int num) { double avg; double total = 0.0; for (int count = 0; count < num; count++) { total += scores[count]; } avg = total / num; return avg; }``````

I am having trouble with the final part of my program. How do I pass the array of test scores to a function that calculates how many people got an A (90+) on the test? The final output should look like this:

 ```The average of those scores is: The number of A grades is: ```

Any help would be appreciated.

Thanks!
You were able to pass it to `getAverage()' ¿don't you?
closed account (3UMLy60M)
Yes, but how do I create a function that can determine exactly how many of the scores were above 90?
Topic archived. No new replies allowed.