int multiplyArray(int arr[], int len) {
//Initialize with 1, not 0 because 0 * anything = 0
int result = 1;
//cycle though the values
for(int i = 0; i < len; i ++) {
//multiply the last result by the current element
result *= arr[i];
}
return result;
}
for(int i = /* First index */; i < /* Last index */; i++) {
// Use an extra variable to keep the 'sum' of the previous multiplications
// *Hint* The first iteration would need to be handled differently than the others since array[i-1] would be invalid
}
The basic idea would be the same, but like integralfx said, change the array type, and also the return type & the type of the variable that stores the current result to a floating-point variable type (i.e.float,double, and longdouble)