1. ## Standard Deviation Function

Code:
```#include <iostream>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

const int N = 1000;
void pass_array(double array[N]);

int main()
{
double x_bar, average();
double s_array[N], sam(0), s;
pass_array(s_array);

x_bar = average();

for (int i=0; i<=5; i++)
{
sam += pow((s_array[i] - x_bar),2);
}

s = sqrt(sam/(i-1));

cout << "sam=:" << sam << endl;
cout << "s=" << s << endl;
cout << "i=" << i <<endl;

return 0;
}

double average()
{
double av_array[N], sum(0), average;
pass_array(av_array);

for (int i=0; i<=5; i++)
{
cout << av_array[i] << endl;
}
for (int j=0; j<=(i-1); j++)
{
sum += av_array[j];
}

average = sum/j;
return average;
}

void pass_array(double array[N])
{
string filename;
ifstream data;
int count(0);

cout << "What is the filename where the data is located?" << endl;
cin >> filename;

data.open(filename.c_str());
if (data.fail())
{
cout << "Error opening file, check file status and try again." << endl;
}
else
while(count < (N-1) && !data.eof())
{
data >> array[count];
count++;
}

}```
I need to call both the average and the standard deviation functions at different times, can anyone tell me how to write this so it doesn't ask me the name of the file twice.

2. Pass the filename as a parameter.

3. How do I do that, I'm unfortunately terrible at this

4. Like
void pass_array(double array[N], string filename)

Move the code you presently have in pass_array to prompt for a filename, and move it to main.
Then pass that as a parameter to whatever functions need it.