i'm trying to calculate the minimum, maximum, average, etc. of an array. using the calcbyaddr function. i keep getting this error and i don't know what it means. i'm getting it at line 27, 63, 64, 72, 74. do i need to change the array to double*ar[]? this is an assignment and in the assignment they specifically show double ar[], so i'm unsure if i'm supposed to be using a * for the array.
Code:
#include <iomanip>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <math.h>
using namespace std;
int i;
void sortarrays (double ar[]);
void calcByAddr( double ar[], int, double*, double*, double*, double*, double* );
int main()
{
double ar[15] = {2.4, 6.5, 1.2, 0.7, 15.3, 3.9, 78.1, 12.0, 5.4, 10.1, 24.0, 7.8, 46.8, 1.3, 0.1};
int num;
double min, max, average, standarddev, median;
sortarrays(ar);
calcByAddr(ar, num, min, max, average, standarddev, median);
return 0;
}
void sortarrays (double ar[])
{
int i, j;
for (i=0; i<15; i++)
{
for(j=i+1; j<15; j++)
{
if(ar[i]>ar[j]) //CONDITION :
{
int temp;
temp = ar[i]; //save a copy of value in i
ar[i] = ar[j]; //copy value from j to i
ar[j] = temp; //copy saved value from i to j
}
}
}
}
void calcByAddr( double ar[], int num, double* min, double* max, double* average, double* standarddev, double* median )
{
int i;
double sum;
min=ar[0];
max=ar[14];
num=15;
for (i=0; i<15; i++)
{
sum+=ar[i];
};
average = sum/num;
median = ar[7];
}