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.
#include <iostream>
usingnamespace std;
// function and array declaration
void getData();
void findAverage();
constint 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;
}
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.