# Thread: How can I find the average in the ARRAYS?

1. ## How can I find the average in the ARRAYS?

I have already wrote the main funstion but I cannot figure out what to put in the other function to find the average of the three arrays?#include <iostream>
#include <iomanip>
using namespace std;

double avg1( double [], int);
double avg2( double [], int);
double avg3( double [], int);
double computeAverage(int [], double []);

int main()
{
double x[] = { 11.11, 66.66, 88.88, 33.33, 55.55 };
double y[] = { 9, 6, 5, 8, 3, 4, 7, 4, 6, 3, 8, 5, 7, 2 };
double z[] = { 123, 400, 765, 102, 345, 678, 234, 789 };

cout << fixed << setprecision(2);

double avg1 = computeAverage (x, sizeof (x) / sizeof (x) );
double avg2 = computeAverage (y, sizeof (x) / sizeof (x));

cout << "Average of numbers in array x = " << avg1 << '\n';
cout << "Average of numbers in array y = " << avg2 << '\n';
cout << "Average of numbers in array z = "
<< ComputeAverage (z, sizeof (z) / sizeof (z)) << '\n';
return 0;
}

double computeAverage ()
{

}

Any help would be appreciated.

Thanks,
Nate2430 2. double computeAverage(double array[], int size)
{
double total = 0;
for (int i = 0; i <= size - 1; i++)
total += array[i];  Popular pages Recent additions 