It doesn't work for multiplication because multiplying anything by 0
gives, well 0
you need to use first element as an initial value
double accumulator(double (*function)(double, double), double array[], int length)
{
int temp = array[0];
for (int i = 1; i < length;i++) // start from #1
{
temp = (*function)(temp, array[i]);
}
return temp;
}