Write a program that reads an unspecified number of scores and determine how many scores are above or equal to the average and how many scores are below the average. Enter a negative number to signify the end of the input. Assume that the number of scores is 1 to 10.
I dunno how to dynamically allocate the size of array based on user input. Any idea?
Is that any way to achieve the goal without using std::vector?
Yes there is. But essentially you end up re-writing the functionality of the vector.
That is, when the capacity of the array is exceeded, allocate a new, larger array, copy all the data from the old to the new and then delete the old.
To do that efficiently, you'd probably want to avoid having to do that on every iteration, so allocate the array somewhat larger than is required each time, and keep track of both the capacity and amount actually used.
And even if you use it, you will still have problems in authors case: assinging a sentiel terminated sequence of unknown size.
If you really do not want to use vector you can overallocate your array. And when num will becomes equal to the size of your current array, reallocate it into array of bigger size.