int getAverage (double tempNumbers[], int size)
{
int i, sum = 0;
int average;
for (i = 0; i < size; i++)
sum += tempNumbers[i];
average = double (sum) / size;
return average;
}
What looks right to me too.
And then we get the line from functions.h that is:
int getAverage (double*, int);
So everything looks fine, but when I run it I still get 2 errors that are:
Error 1 error LNK2019: unresolved external symbol "int __cdecl getAverage(double *,int)" (?getAverage@@YAHPANH@Z) referenced in function _main E:\C++\Assigment2-Right\Assigment2-Right\Task4.obj Assigment2-Right
It runs now!! However, at the end my result is 16 and not 16.21 but that's ok I can fix that later heheh going to work on the max and min values now...
So I need a for loop to sort the arrays and then print the first array for the min temp and the last array for max temp right?
double minTemp(double tempNumbers[], int size)
{
double minTemp = tempNumbers[0];
for (int i = 0; i < size; i++)
{
if (tempNumbers[i] < minTemp)
minTemp = tempNumbers[i];
}
return minTemp;
}
Try this and modify it to get maxTemp. I'd suggest you have two funcyions, one for max and one for min. You can do them together but it is clearer if they are separate.