Arrays are passed by reference (address) by default.
Function takes an array and tries to return average, sum of elements, and the sum of the squares.
Calculate and display sum, sumsq using for loop in the function definition display sum, avg, and sumsq to see the difference between the values inside and outside function. If you see any difference explain why?
This is what I have:
void stats(double a[], int n, double & avg, double & sum, double & sumsq)
{
int i;
avg = 0.;
sum = 0.;
sumsq = 0.;
//how to calculate and display sum, sumsq using for loop in the function definition?
}
void main() {
double a[3] = {1, 3, 5};
double avg = 0, sum = 0, sumsq = 0;
stats(a, 3, avg, sum, sumsq);
//how to display sum, avg, and sumsq to see the difference between the values inside and outside function?
}