Code:
# include <FPT.h> // finding mean and standard deviation
int main()
{double d[1000],s,x,n,z,m,i,c;
outS("enter the numbers: ");
x=inD();n=0;
if(x<0){outS("no data");outS("\n");exit(0);}
while(x>=0){
d[n]=x;
s=s+x;
n=n+1;
x=inD();
}
m=s/n;
outS("This is the Mean: ");outD(m);outS("\n");
i=0;z=0;
while(i>n);{z=z+(d[i]-m)*(d[i]-m);i=i+1;}
outS("This is the Standard Deviation: ");outD(sqrt(z/n));outS("\n");
}
I am trying to find the mean and standard deviation of entered numbers. But the standard deviation part does not work as I expected. Please, please help me. Thanks a lot.
PS: I am new to C language, our professor only taught us how to program by using this kind of language and I couldn't find any reference information by looking around on the Internet. It's kind of different from what people would always use in C. Does anyone know any book or reference site I can go to get a better understanding of this language? Thanks a ton.