Prompting user for input into an array

I am having trouble with a homework assignment for c++. I need to declare an array that can hold up to 1000 data points. Then I need to prompt the user to ask how many datapoints there are in the dataset. And then prompt the user to enter data from the keyboard using repetition structures. Then I need to calculate the average, standard deviation, maximum, minimum, and range of that dataset. Here's what I have so far and I'm not sure where to go from here.

int main()
{
int arraySize = 1000; //define array
cout << "Enter number of data points:" << endl;
cin >> arraySize;

int arrayElement[arraySize]; //declares array with input size
cout << "Enter data points:" << endl; //prompts user to enter values for array
}

I'm not sure if I even did this right but any help would be greatly appreciated. Thank you.
If you want to create an array which the size is chosen by the user, you would have to create it dynamically.

http://www.cplusplus.com/doc/tutorial/dynamic/

Also, it's kinda pointless declaring an array that can hold up to 1000 data points, if you're then just gonna ask the user to write over the number 1000 with their own number.
Last edited on
Topic archived. No new replies allowed.