# Help!! My last project of the year!! I'm almost done

This is a discussion on Help!! My last project of the year!! I'm almost done within the C++ Programming forums, part of the General Programming Boards category; I have this function in a separate file to be called in the main program. I know that i have ...

1. ## Help!! My last project of the year!! I'm almost done

I have this function in a separate file to be called in the main program. I know that i have to have a for statement under the first one where i already figured the sum. Please help.

Code:
//-----------------------------------------------------------------------------
// deviation function
//
//-----------------------------------------------------------------------------
#include <cmath>
double deviation(double list[], int size)
{
double total=0;
double average;
double S;
double U;
double sum;

for(int x = 0; x<size; x++){
total += list[x];
}
average = total/size;

for(
S = (sqrt (U / size));

return S;

}

2. So what do you need - the sum of square roots of each list[x] ?

You already have a for loop dealing with list[x].
If that is what you need to do again, what is the problem?

3. i found the average already but i need to figure the standard deviation of the array.

4. So is this a math question then?

Maybe do a google search for "How to calculate standard deviation"

5. Its a question of how do i write it in c++

6. calculate standard deviation - Google Search

From Wikipedia
1. Find the mean, \scriptstyle\overline{x}, of the values.
2. For each value \scriptstyle x_i calculate its deviation \scriptstyle x_i \,-\, \overline{x} from the mean.
3. Calculate the squares of these deviations.
4. Find the mean of the squared deviations. This quantity is the variance σ2.
5. Take the square root of the variance.
You've done step 1, now try step 2.