(C++) My program should be getting the user to input numbers which will determine the size of the array and as well as what its elements are. I then need to sort out the elements in an ascending order. My problem is whenever I run my program and it displays the sorted numbers; instead it displays the address(if I'm correct).
#include <iostream>
using namespace std;
int main()
{
int size;
int i,x,tempVar;
cout << "Enter how many students took the test: ";
cin >> size;
int *myArray = new int [size];
for ( i = 0; i < size; i++)
{
cout << "Enter a score: ";
cin >> myArray[size];
}
for ( i = 0; i < size; i++)
{
for ( x = 0; x < size; x++)
{
if (myArray[i] < myArray[x])
{
tempVar = myArray[i];
myArray[i] = myArray[x];
myArray[x] = tempVar;
}
}
}
cout << "The scores have been sorted out in an ascending order\n";
for (i = 0; i < size; i++)
{
cout << *(myArray + i) << endl;
}
delete [] myArray;
}