I am making a program that solves for Standard Deviation unfortunately my program
doesn't print correct answer but just prints the 1.#J or the infinity error if I am right

I can't figure out what is the problem with my codes can someone help me to debug..
because I don't have enough knowledge about pass by reference

here is the code

Code:
```//Prototypes
double Standard();
double EvalStandard(double mean,double calc,int b,double data[]){
int a;
double sum,sd;
for(a=0;a<b;a++){
sum=sum+data[a];
}
mean=sum/a;
for(a=0;a<b;a++){
calc+=pow((data[a]-mean),2);
}
sd=sqrt(calc/(b-1));
return sd;
}

//Function
//Standard Deviation Function
double Standard(){
int SA,a,b;
double sum=0,data[10],mean,calc,sd;
char error[128];

do{
system("cls");
printf("Standard Deviation\n\n");
printf("Enter the Number of Data (max. 10): ");
scanf("%s",&error);
b=atoi(error);
if(b>10||b==0){
system("cls");
printf("Please press the spacebar to continue!!\n");
getche();
}
}while(b>10||b==0);
for(a=0;a<b;a++){
printf("Enter the Actual Values of Data %d: ", a+1);
scanf("%s",&error);
data[a]=atof(error);
}
if(b==1){
printf("The Standard Deviation the Data is 0\n");
printf("Please press the spacebar to continue!!");
getche();
}
else{
sd=EvalStandard(mean,calc,b,data);
printf("The Standard Deviation the Data is %.2lf\n",sd);
printf("Please press the spacebar to continue!!");
getche();
}
}```

Last edited by askmewhy25; 4Mar2010 at 19:35..
abubacker1 like this