I'm writing a program to work out a value from two arrays. I'm having trouble with passing and using arrays in my functions. Here is my code:
#include <stdio.h> #include <string.h> #include <math.h> const int MAX_STRING = 100; double mean(double mean_array[]){ double mean; for (int i=0; i<=2000000; i++){ mean = mean + mean_array[i]; } mean = mean/2000000; return mean; } double stan_dev_seq(double stan_array[]){ double mean = mean(stan_array); double a; for (int i=0; i<=2000000; i++){ a = a + pow(stan_array[i]-mean, 2); } a = sqrt(a/2000000); return a; } int pearson_seq(void){ double a[2000000]; double b[2000000]; double mean_a; double mean_b; for (int i=0; i<=2000000; i++){ a[i] = sin(i); b[i] = sin(i+2); } double stan_dev_a = stan_dev_seq(a); double stan_dev_b = stan_dev_seq(b); return 0; } int main(void) { pearson_seq(); return 0; } And here is the error I get:
person_mpi.c: In function ‘stan_dev_seq’: person_mpi.c:22:16: error: called object ‘mean’ is not a function or function pointer double mean = mean(stan_array); ^ person_mpi.c:22:9: note: declared here double mean = mean(stan_array); ^ I'm not really sure what is going on, any help would be appreciated.