i am kind of stuck with some code that im doing. what i have to do is in the comments.

```
//Write a function that computes the average value of an array of floating-point data:
//double average(double* a, int size)
//In the function, use a pointer variable, not an integer index, to traverse the array
//elements.

#include <iostream>

using namespace std;

double average(double* a, int size)

{
    double total = 0;
    double* p = a;
    // p starts at the beginning of the array
    for (int i = 0; i < size; i++)
    {
        total = total + *p;
        // Add the value to which p points
        p++;
        // Advance p to the next array element
    }
    return total / size;
}

```

to start with its not running. and 2ndly, am i actually going about doing the problem correctly? basically i tried following the book to go through all elements and then average it out after... but i have this strong feeling im missing something.

sorry if this seems to obvious for some of you guys. my still pretty new to all of this and my teacher doesn't exactly... well she doesn't teach us the coding aspect of C++. all she does is read from 5 out of 200+ slides and does hand tracing(not even pseudo code) and then throws us to the wolves by randomly picking us a coding assignment. the way she teaches is basically as if we already know how to code, which some of us do and some of us(like me) are seeing this for the very first time.

she hasnt even taught us how to use the compiler, so we are basically learning all of this ourselves. arg, sorry i went on a rant there. anyway can someone help with this?