
An L. answered 12/06/19
Adjunct Professor Computer Science
I can give you some hints, but not the entire solution. There are 2 methods to allocate the array that is large enough to store scores:
Use vector:
#include <vector>
// Declare dynamic score array and read in scores:
vector<int> myscores(20); // 20 is the initial size your dynamic array
// read each score by using cin:
// you need a while-loop to read in each score
cin >> myscores[i];
Ask the user for the max number of score and dynamically allocate enough storage:
int *mycores = new int [number_of_scores];
// Use a while-loop to read in each scores similar to above
The sorting function prototype should be:
void sort_scores(int *myscores, int score_count)
// myscores: the input score array
// score_count: the number of scores in myscores array
// Your text book should have an example of sorting an integer array
The average function prototype should be:
float average((int *myscores, int score_count)
// You should be able to figure out the rest