The first problem is that you haven’t declared your function before using it in main()
. Provide a declaration or prototype before calling it.
double avg(int a[], int *n);
int main() {
...
Second, in the first implementation, you are not storing the return value of the function
avg (arr, & size) ; // useless statement
Just store the return value into a variable and print it, it will work as expected
double average = avg (arr, & size);
printf("%lf", average);
2
solved Can I return a double or float in a function with two integer parameters?