15,610,588 members
See more:
```#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;
//function prototype
int AVSD(double[], double&, double&, const int);
int max;

int main() {
const int SIZE = 10;
int index = 0;
double average = 0, SD = 0;
double studyHour[SIZE] = {10,16,15.65,17,16.3,20,10.5,17.5,12 };

index = AVSD(studyHour, average, SD, SIZE);
cout << "Details of Practical Group 1" << endl;
cout << "Average:" << average<<endl;
cout << "Standard Deviation:" <<SD<< endl;
cout << "Highest study hour" <<studyHour[max]<<endl;
system("PAUSE");
return 0;
}

int AVSD(double studyHour[], double& average, double& SD, const int SIZE) {

double sum = 0;
for (int i = 0; i < SIZE; i++) {
sum = sum + studyHour[i];
average = sum / SIZE;
}

double total = 0;
for (int i = 0; i < SIZE; i++) {
pow((studyHour[i] - average), 2);
total += pow((studyHour[i] - average), 2);
}
SD = sqrt(fabs(total / SIZE));

for (int i = 0; i < 10; i++) {
if (i == 0) {
max = i;
}
else {
if (studyHour[i] > studyHour[max])
max = i;
}
return max;
}
}```

What I have tried:

I haven't try anything cause i don't really know what to do...
Posted
Updated 13-Aug-21 21:59pm
v2

## Solution 1

C++
`using namespace std;`
and declared a global variable:
C++
`int max;`
Since `std` contains `std::max` the compiler isn't sure which `max` you mean.

Change your variable name, or remove the `using` line.

## Solution 2

OriginalGriff is right, but best is to remove all global variables not only because max is a bad and too short name.

When you read your code you will find that AVSD() is already returning the value and so you can work with that.
You also only need one loop in AVSD() and rethink your max calculation. I start with the first value outside the loop and than check for higher values.