Hello this is for an assignment. I'm not looking for the answer but rather a point in the right direction. The areas where I have comments are places I still need to fill in. And I need help knowing if what little I have right now is right or very wrong. I haven't done programming in a while and have suffered for it.
The sample run is supposed to look like this.
Welcome to Pat Programmer's Quiz Score Calculator
How many test scores will you enter? 5
Enter test score 1: 60.00
Enter test score 2: 70.00
Enter test score 3: 80.00
Enter test score 4: 90.00
Enter test score 5: 100.00
The test scores in ascending order, and their averages, are:
Not sure what you are asking. You have an int pointer and allocate it into a dynamic array correctly.
I personally avoid pointer syntax in favor of array syntax
*(arrayPtr + i) = temp;
looks like
arrayPtr[i] = temp;
it looks good, just incomplete.
the sort seems odd, with the while(1). The standard sorts would just loop using the array's size. I am not sure the sort is correct or not, but if it is working, leave it be and focus on the other stuff.
Given what is there I can't see anything you should not be able to do. If the sort works, I would say its on the right track.
I'm pretty new to pointers and this assignment I'm supposed to use them. I've also never done bubblesort before and I'm supposed to use that in order to get the user input sorted in ascending order. I'm not sure I'm doing it right personally.
The comment
// declares a pointer to an array of doubles
In getScores you know how to create an pointer to an int array. Just change int to double.
BTW. getScores is supposed to return a double* but you return an int*
int *arrayPtr = NULL;
cout << "How many test scores will you enter? " << endl;
int scores;
cin >> scores;
// Dyanamically allocate array
arrayPtr = new int[scores];
for a double, change int to double: //losing the pointless null assignment and rolling into one statement
double * d = new double[some_size];
bubble sort is a pair of for loops over the size of the array. the inner loop moves the smallest value to the top, and the outer loop cuts the array down by 1 each time and does the inner loop on the new, reduced array (because you skip the sorted values that you already moved).
so 4321
inner loop 1 moves 1: 1432
inner loop 2 moves 2: 1243
inner loop 3 moves 3: 1234
inner loop 4 moves 4 which happens to be correct (you can skip this last iteration if you like).