# Standard deviation

• 04-20-2009
Dontgiveup
Standard deviation
Code:

```//Here is what I got so far #include <iostream> using namespace std; int main () {   int n, median;   double standarddeviation;   int num [31]={12, 13, 15, 16, 18, 19, 21, 34, 57, 32, 38, 213, 10, 14, 156, 172, 134, 143, 132, 139, 751, 30, 31, 81, 23, 41, 24, 51, 75, 91, 1234};   int sum= 0;   for (n=0; n<31; n++)   sum = sum+num [n];   double average=sum/31.0;   standarddeviation=(num[n]-average)*(num[n]-average);//I want to multiply every number by itself, subtract from the mean and son on but I can't seem to get it   cout<< sum<<endl;   cout<<average<<endl;   cout<<standarddeviation;   return 0;   }```
• 04-21-2009
m37h0d
does this make your problem clearer?

Code:

```  for (n=0; n<31; n++)   {   sum = sum+num [n];   }   double average=sum/31.0;   standarddeviation=(num[n]-average)*(num[n]-average);//I want to multiply every number by itself, subtract from the mean and son on but I can't seem to get it```
• 04-21-2009
iMalc
Look at the standard deviation formula again. In no way does it involve an average as part of the calculation.
You also need to calculate the sum of the squares of the input data as well as just the sum of the input data.
Last of all, you will need the square root function.
• 04-21-2009
laserlight
Quote:

Originally Posted by iMalc
Look at the standard deviation formula again. In no way does it involve an average as part of the calculation.

But it does, specifically, the mean.
• 04-22-2009
iMalc
Quote:

Originally Posted by laserlight
But it does, specifically, the mean.

Well it's squared, that's what I meant.