need help on writing standard deviation code

hi, i m working on a stardard deviation c++ code
my assignment is to find the std. dev. of " double x[] = {2,4,4,4,5,5,7,-9}; "
and i dont know why my instructor require us to put "double stddev(double arg[], int length)" this as the variable of the std dev
and here is what i have so far...
 ``1234567891011121314151617181920212223242526272829`` ``````#include #include using namespace std; int main() { double x[] = {2,4,4,4,5,5,7,-9}; double stddev(double arg[], int length); double mean; double sum; double sum2; for ( int i = 0; i <=8; i++ ) { sum += x[i]; } mean=sum/8; for ( int i = 0; i <=8; i++ ) { sum2 += pow((x[i]-mean),2); } stddev=sqrt(sum2/(7)); cout << "S.D.: " << stddev(x,8) << endl; return 0; } ``````

Hoping expert can help:>
Line 8: this is a function forward declaration
I believe that you are supposed to do something like:
 ``12345678910111213`` ``````double stddev(double arg[], int length); int main() { double x[] = {2,4,4,4,5,5,7,-9}; //Length of 8 double dev = stddev(x, 8); std::cout << "S.D.:" << dev << std::endl; } double stddev(double arg[], int length) { /*Calculate standard deviation here and return the result*/ }``````

Topic archived. No new replies allowed.