This works:
for(int i = 0; i < size; i++){
avg[0] = avg[0] + array0[i];
avg[1] = avg[1] + array1[i];
avg[2] = avg[2] + array2[i];
avg[3] = avg[3] + array3[i];
}
However, this doesn't:
for(int i = 0; i < size; i++){
avg[0] =+ array0[i];
avg[1] =+ array1[i];
avg[2] =+ array2[i];
avg[3] =+ array3[i];
}
In the second example, the array doesn't add to itself.
See Question&Answers more detail:os