Help with Dynamically Allocates Array Program

Write a program that dynamically allocates an array large enough to hold a userdefined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible.
Input Validation: Do not accept negative numbers for test scores.

I tried to write it like this and it show me this issue with this program as in line 50 when I compile it, it gave me an error message: expression must have a constant value.

Thanks in advance.

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <iomanip>

using namespace std;
//Function prototypes
void arrSelectSort(double *, double);
// passing an array of doubles, not ints!

int main()
{
	double *TestScores,  //To dynamically allocate an array
		total = 0.0,  //Accumulator
		average; //To hold average test scores
	int numTest, //To hold number of test scores
		count; //Counter variable

	//Get the number of test scores you wish to average and put in order
	cout << "How many test scores do you wish ";
	cout << "to enter? ";
	cin >> numTest;

	//Dynamically allocate an array large enough to hold that many scores
	TestScores = new double[numTest];

	//Get the test scores
	cout << "Enter the test scores below.\n";
	for (count = 0; count < numTest; count++)
	{
		cout << "Test Score " << (count + 1) << ": ";
		cin >> TestScores[count];
	}

	//Calculate the total test scores
	for (count = 0; count < numTest; count++)
	{
		total += TestScores[count];
	}

	//Calculate the average test scores
	average = total / numTest;
	//Display the results
	cout << fixed << showpoint << setprecision(2);
	cout << "The average of all the test score is " << average << endl;

	//Free dynamically allocated memory
	delete[] TestScores;
	TestScores = 0; //make TestScores point to null

	//An array of pointers to int
	int *arrPtrTestScores[count];

	//Sort the elements of the array of pointers
	arrSelectSort(TestScores, TestScores[count]);

	//Display the Test Scores in ascending order
	cout << "The test scores, sorted in ascending order, are: \n";
	return 0;
}

//This function performs an ascending order selection sort
void arrSelectSort(double *arr, int size)
{
	int startScan;
	double minIndex; // one data type
	double minElem; // has to be the same data type

	for (startScan = 0; startScan < (size - 1); startScan++)
	{
		minIndex = startScan;
		minElem = arr[startScan];
		for (int index = startScan + 1; index < size; index++)
		{
			if (arr[index] < minElem)
			{
				minElem = arr[index];
				minIndex = index;
			}
		}
		
		// to cast it~ (int)variable will cast it to an int
		arr[(int)minIndex] = arr[startScan];
		arr[startScan] = minElem;
	}
}
What is the purpose of line 50?

What is the second parameter on function call on line 53?
Topic archived. No new replies allowed.