0

In this code I want to have a function to show average of movies saw by students, how to define and declare and call it in this program:

```
#include <iostream>
#include <iomanip>
using namespace std;
/****************Function Prototypes******************/
void displayList(int [], int); //function to display array
void getAverage (int [], int);
void getMedian (int [] , int);
int getMode (int [], int);
/***************main***********************/
int main()
{
int *movies,
total = 0,
average,
numDays,
count,
numStudent; // desired size of the array 'students'
int* students = NULL; // pointer to an int, initially to nothing
cout << " *** Student Movie Analysis ***\n\n";
cout << "Enter the number of Students: ";
cin >> numStudent;
// ** Dynamic allocation of Array size 'n' **
students = new int[numStudent]; // Allocate 'numStudent' ints and save in ptr 'students'
for (int i=0; i<numStudent; i++)
{
students[i] = 0; // initialize all elements to zero
}
Get the number of movies from the user
cout<<"Enter the num. of movies below.\n";
for (count = 0; count < numStudent; count++)
{
cout << "Student # " << (count + 1) << " : ";
cin >> students[count];
}
//Calculate the total movies
for (count = 0; count < numStudent; count++)
{
total += students[count];
}
//Calculate the average movies per month
average = total / numStudent;
//Display the results
cout << "\n\nTotal Movies: " << total << endl;
cout << "Average : "<< average << endl; */
delete [] students; // When done, free memory pointed to by 'students'
students = NULL; // Clear 'students' to prevent invalid memory reference
cout << "End of Program.\n";
system("PAUSE");
return 0;
}
```

here is my average Function but it shows overloading error why i dont know

```
void getAverage( int list[], int numStudent)
{
for (count = 0; count < numStudent; count++)
{
total += students[count];
}
// Calculate the average movies in a month
average = total / numStudent;
```

how to call it @ main

*Edited 7 Years Ago by rafta*: n/a