Question 2
This question involves a function that process rainfall data. The function is to be given
1/. A double array containing rainfall data for N consecutive days (array[0] = rainfall for the first
day, array[1] = rainfall for the second day, and so on).
2/. The value of N.
3/. A value M. This value is guaranteed to be less than or equal to N.
The function is to
1/. Calculate and return the average rainfall over all N days.
2/. Calculate and "return" the average rainfall over the M wettest consecutive days.
3/. "Return" the array position at which the data for the M wettest consecutive days begins.
Examples:
array = [ 0.0, 1.0, 2.0, 1.0, 4.0, 2.0, 0.0, 1.0], N = 8, M = 4
average rainfall = .
..
average for the 4 wettest consecutive days = .
...
the data for these days starts at array position 2
Question 3
Part 1:
Write a function that, given an array of integer values and the size of this array, returns the
position in the array (i.e. the array index) of the lowest value. If the lowest value is repeated
multiple times the position of the first of the repeated values should be returned.
Examples:
array contains [5, 3, 6, 1, 2, 9]
function should return 3
array contains [7, 3, 0, 3, 7, 3]
function should return 2
Part 2:
Write a function that, given an array of integer values, the size of this array, and some value N,
returns true if any of the values in the array is greater than N (and false otherwise).
Examples:
array contains [5, 3, 6, 1, 2, 9],
N is 20
function should return false
array contains [7, 3, 0, 3, 8, 3],
N is 6
function should return true