The deviation
function throws me the following error: "Array subscript is not an integer"
. If you can help me locate the cause of error I'll appreciate it.
float average(float data[], int n) {
float total = 0;
float *p = data;
while (p < (data + n)) {
total = total + *p;
p++;
}
return total / n;
}
float deviation(float data[], int n) {
float data_average = average(data, n);
float total;
float *p = data;
while (p < (data + n)) {
total += (data[p] - data_average) * (data[p + 1] - data_average);
}
return total / 2;
}