- #1

- 29

- 2

## Summary:

- Standard Deviation

## Main Question or Discussion Point

Code:

```
#include<stdio.h>
#include<math.h>
double foo(int n, int mean){
double square;
if(n==1){
return(1);
}
if(n!=0){
square=pow(n-mean,2);
return( (sqrt(square)+foo(n-1,mean))/(sqrt(n-1)) );
}
}
int main(){
int num;
double mean;
int i;
int sum=0;
printf("Enter the number: ");
scanf("%d",&num);
for(i=1; num>=i; i++){
sum=sum+i;
}
mean=(double)sum/num;
foo(num,mean);
printf(" %lf ",foo(num,mean));
}
```

I want to calculate standard deviation. For example if the input is 6, I want to do this: sqrt( (6+5+4+3+2+1)/(5) ) . If the input is 6, output is going 2.100528. My code does not work properly.