0

For a homework assignment I need to write a function that computes the average value of an array of floating-point data:

double average(double* a, int a_size)

In the function, use a pointer variable, and not an integer index, to traverse the array elements.

The code below is what I have so far but I don't know what I can do to make it better. Any help or comments will be appreciated!

Dennis

```
#include <iostream>
using namespace std;
double average (double* a, int a_size)
{
double total;
double average;
double* p = a;
for (int i = 1; i < a_size; i++)
{
total = total + a[i];
average = total / a_size;
}
return average;
}
int main()
{
return 0;
}
```