Average from array keeps returning address?

for my hw assignment, i had to write a program with 2 functions and an array to gather grades and then calculate the average of the grades. I am currently stuck on getting the average, as it seems to be printing the address of the array rather than the average of the numbers being inputted by the user. below is my code, thank you in advance for any help!

**code has been edited. now i recieve NO value rather than the address.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 #include <iostream>

using namespace std;
// function and array declaration

void getData();
void findAverage();
const int SIZE = 10;
float allGrades[SIZE];

//main begins -------------------------------------------------
int main()
{
    cout << "here we will find the average of your grades \n";
    cout << "please enter your grades below" << endl;
    getData();
    
    cout << endl << "the average grade is: ";
    findAverage;
    return 0;
}
// main ends --------------------------------------------------
void getData()
{
    int i = 0; //increment int

    for (int i = 0; i < 10; i++)
    {
        cout << "enter a grade: ";
        cin >> allGrades[i];
    }
}


void findAverage()
{
    int i = 0; // increment int
    double sum = 0, avg;
    for (int i = 0; i < 10; i++)
    {
        sum += allGrades[i];
    }
    avg = sum / 10;
    cout << avg;
}
Last edited on
divide only once, not every loop, in find average.
didnt even notice that, thanks for the help with that, but it is still returning the address rather than the value for some reason. i am not sure what i'm doing wrong at this point
so after testing by removing the findAverage function and just declaring it in main, I am pretty sure my issue is in the call to findAverage, but i am unsure where i am going wrong. it still sends the address of the array rather than the average calculated by the function.
findaverage call line 19 needs ()
wow, yup that did it right there! been driving me nuts trying to figure it out lol. thanks for your help jonnin!
Topic archived. No new replies allowed.