i understand how things work here now. i fixed the things that you guys suggested and im getting values now. no more nan outputs. The only thing now is that even though I have specified that the values are to be floats. I am still getting whole numbers. here is my code:
Code:
/*mean accepts the current index position, the array
pointer, and the count to determine the mean*/
int mean(int index, int *data_in, int integer_count){
float sum=0;
float mean=0;
for(index = 0; index!=integer_count; index++){
sum = sum + data_in[index];
}
mean =(float) ((sum)/(integer_count));
mean2 = (float)mean;
return mean2;
}
}
/* This function computes the standard deviation, sigma.*/
int std_deviation(int i, int *data_in, int integer_count){
int d,g = 0;
float sq_diff = 0;
float diff = 0;
float variance;
/*For loop to access the input array and uses integer count to piece together the std. formula*/
for(d=0; d<integer_count;d++){
g= data_in[d];
diff = g - mean2;
data_diff[d]= diff;
sq_diff += diff*diff;
data_diff[d] = (float) data_diff[d];
}
variance = sq_diff/integer_count;
std = sqrt(variance);
return std;
}
and this is the printf statement that i am using.
Code:
printf("Number of entries = %3d, mean = %3.2f, sigma = %3.2f\n",integer_count,(float)avg,(float)sigma);
it seems to be something small that I am missing...