### Need help

Write a program that computes the central tendencies mean (average), mode, median and the variation: variance, standard deviation and range for a set of numbers given in the data file ArsenicGroundWaterFile.txt.

The following data represent (naturally occurring) concentration of arsenic in ground water for a random sample of 102 Northwest Texas wells. Units are parts per billion.
Reference: Nichols, C.E. and Kane, V.E., Union Carbide Technical Report K/UR-1

The output should be as follows to two decimal places:

Central Tendency Variation

Mean xxx.xx Variance xxx.xx

Median xxx.xx Std. Dev xxx.xx

Mode xxx.xx Range xxx.xx

I have no idea how to do this assignment, my professor hasn't been of any help. Please help me get started.
Start by reading the values from the file into an array. Do you know how to do that?
No I am not familiar with how the do that.
Okay i read over that and it helped some but i'm still very confused.
Could you post what you have?
I just have it right now to where it will read the file and display what is in it.

 ``12345678910111213141516171819202122232425262728`` ``````#include #include #include #include using namespace std; ifstream myFile; double Value; int main() { ifstream myfile("numbers.txt"); if(myfile.is_open()){ while(myfile >> Value){ cout << Value << endl; } } } ``````
After that you need to store the values, the C++ way is to use a `std::vector` but you may be expected to use an array.

By the way, avoid global variables - lines 9 and 10 in above code, better removed and declared locally instead.

1. use a vector

 ``1234567891011121314151617181920212223242526272829303132333435`` ``````#include #include #include #include #include using namespace std; int main() { // Open file and check it is open ifstream myfile("numbers.txt"); if (!myfile) { cout << "could not open input file\n"; return 1; } // read all values from file into a vector vector data; double value; while (myfile >> value) { data.push_back(value); } // Output contents of vector cout << "Number of values: " << data.size() << '\n'; for (size_t i = 0; i < data.size(); i++) { cout << data[i] << endl; } }``````

2. same functionality (more or less) using an array instead:
 ``12345678910111213141516171819202122232425262728293031323334353637383940`` ``````#include #include #include #include using namespace std; int main() { // Open file and check it is open ifstream myfile("numbers.txt"); if (!myfile) { cout << "could not open input file\n"; return 1; } // Allocate an array - estimate size required const int SIZE = 1000; // Maximum number of values double data[SIZE]; // define an array we hope is large enough int count = 0; // keep track of how many values are stored. // read all values from file into an array double value; while (count < SIZE && myfile >> value) // while array is not full, read a value { data[count] = value; // store it count++; // increaase count } // Output contents of array cout << "Number of values: " << count << '\n'; for (int i = 0; i < count; i++) { cout << data[i] << endl; } }``````