PLEASE HELP ARRAYS

Hi im having a hard time on where to go from here or if im already doing something wrong. I posted my prompt on the bottom.

getGrades()
Write a function to prompt the user for ten grades and return the result back to main(). Note that any variables declared in getGrades() will be destroyed when the function returns. This means that main() will need to declare the array and pass it as a parameter to getGrades().
averageGrades()
Write another function to find the average of the grades and return the answer. Of course, the grades array will need to be passed as a parameter. The return value should be the average.
main()
Finally, create main() that does the following:
◾Has the grades array as a local variable
◾Calls getGrades()
◾Calls averageGrades()
◾Displays the result


int getGrades(int grade[])
{
cout << "Grade 1: ";
cin >> grade;

cout << "Grade 2: ";
cin >> grade;

cout << "Grade 3: ";
cin >> grade;

cout << "Grade 4: ";
cin >> grade;

cout << "Grade 5: ";
cin >> grade;

cout << "Grade 6: ";
cin >> grade;

cout << "Grade 7: ";
cin >> grade;

cout << "Grade 8: ";
cin >> grade;

cout << "Grade 9: ";
cin >> grade;

cout << "Grade 10: ";
cin >> grade;

return grade;
}

int averageGrades(int grade[], int average)
{
average = grade /10;
cout << "Average Grade: " << average <<endl;

return average;
}



int main()
{
int grade[10]
int average = averageGrades(grade, average);
return 0;
Hope this is what you are looking for.

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
#include <iostream>
using namespace std;
/******************************************************************
 * This function will get the Grades!!
 ****************************************************************/
int getGrades() {
	const int SIZE = 10;
	int Grades[SIZE];
	float average;

	for (int i = 0; i < SIZE; i++)
// Fill the list
			{
		cout << "Grade " << i + 1 << ": ";
		cin >> Grades[i];
		average += Grades[i];
	}
// get Average
	average = average / SIZE;
	cout << "Average Grade: " << average << "%" << endl;
	return average;
}

/**************************************************
 * main function
 ****************************************************/
int main() {
// display the result

	getGrades();

	return 0;
}
Topic archived. No new replies allowed.