LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Source code objective (https://www.linuxquestions.org/questions/linux-newbie-8/source-code-objective-4175494854/)

1969JCW 02-13-2014 10:02 PM

Source code objective
 
I'm trying to figure out what this source code does. I keep on getting an error message.

#include<stdio.h>
#include<math.h>

double number_array[30];
int count = 0;

double calc_sum();
void print_list();
double get_number();

double calc_mean(double *list) {
double sum = calc_sum(list);
return sum / count;
}

double calc_std_dev(double *list) {
int index = 0;
double sum = 0;

double mean = calc_mean(list);

while (list[index] != 0) {
sum += (list[index] - mean) * (list[index] - mean);
index++;
}

return sqrt(sum / (count -1));
}

void create_list() {
int number = 0, index = 0;

do {
number_array[index] = get_number();
number = number_array[index++];
} while (number != 0); // if user enter 0, quit

count = index - 1;
}

void read_from_file() {
}

int main() {
create_list();
print_list(number_array);
printf("mean = %f \n", calc_mean(number_array));
printf("std dev = %f \n", calc_std_dev(number_array));
}

John VV 02-13-2014 10:37 PM

please use code tags!!!!
PHP Code:

 [codethe code that NEEDS TO BE IN BETWEEN THE TAGS [/code

this is what it is supposed to do it you were to post all of it
Code:

printf("mean = %f \n", calc_mean(number_array));
printf("std dev = %f \n", calc_std_dev(number_array));

and without knowing what that unknown error is
there is no way to help

so
PLEASE READ the guide on posting
http://www.linuxquestions.org/linux/...Ask_a_Question
and included the NEEDED information

the operating system you are using ?
the version of said OS ?
the FULL build line you are using
and the MOST important part
THE ERROR !!!!!


All times are GMT -5. The time now is 12:26 AM.