The directions:
The following function supposedly computes the sum and average of the numbers in the array a, which has length n.avg and sum point to variables that the function should modify. Unfortunately, the function contains several errors; find and correct them.
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- void avg_sum(double a[], int n, double *avg, double *sum)
- {
- int i;
- sum = 0;
- for (i = 0; i < n; i++)
- sum += a[i];
- avg = sum / n;
- }
in the line [i]sum += a;
Thanks. Please advise.
PS. I am using the problem C - Free 4.1 to write the program in a Vista 64 bit system. If you have a better program, please don't hesitate to tell me.