Finding the Standard deviation from a structure of numbers
Posted on 2003-11-25
Im trying to find the standard deviation from a structure of numbers.
the array is in the format:
were x is incremented for every user.
heres the code for the standard deviation, its in the form of a function initalised using:
float stdDev(struct student s, int n);
and called using:
heres the function... it just crashes! theres 5 entrys, which should be passed to the function in n
float stdDev(struct student s, int n)
float mean, sigma;
mean = s[x].sid / n;
for (x=0; x<5; x++) n += (mean - s[x].mark)*(mean-s[x].mark);
sigma = sqrt(n/5);
printf("Std Deviation is %f",sigma);