the sum divided by the number of numbers being added. My confusion is how to call the sum found in the previous function into my function that computes the average.
Thanks, got that worked out. Ran into one last issue, the findElementsGreaterThan function is for finding elements that are greater than the average. After locating these elements, they are to be stored in an array and displayed.
My function I have been working on is
void findElementsGreaterThan(double threshold, const int ar[], const int n, int foundElements[], int& count) {
int a = 0;
int sum = 0;
for (a = 0; a < n; a++)
{
sum+=ar[a];
}
double average = sum/n;
threshold = average;
for(int i = 0; i < n; i++) {
if (ar[i] > threshold) {
foundElements[count + 1] = ar[i];
}
}
}
Still with one last issue, the findElementsGreaterThan function is for finding elements that are greater than the average. After locating these elements, they are to be stored in an array and displayed.
My function I have been working on is
void findElementsGreaterThan(double threshold, const int ar[], const int n, int foundElements[], int& count) {
int a = 0;
int sum = 0;
for (a = 0; a < n; a++)
{
sum+=ar[a];
}
double average = sum/n;
threshold = average;
for(int i = 0; i < n; i++) {
if (ar[i] > threshold) {
foundElements[count + 1] = ar[i];
}
}
}