Hi I have to Write a function which accepts an array of doubles and its length as parameters and returns the sum of all positive values less than 24 within the array. If the array contains 5, 8.3, 29, -2 and 7, the function will return the value 20.3 (=5 + 8.3 + 7). I also have to write a main method which populates an array with random values, passes the array and its length to the function and outputs the returned value to the screen.
so far I have this:
double sumValues (double nums[], int len) {
int i, sum;
for (i=0; i < len; i++) {
if (nums[i] < 24 && nums[i] >= 0) {
sum = sum + nums[i];
}
}