oldexamquestions

# oldexamquestions - Question 2 This question involves a...

This preview shows pages 1–3. Sign up to view the full content.

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

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Question 4 A professor who has been teaching an introductory programming course for some time maintains a record of the results of lab tests. The information is stored in a file. Each line of this file contains a term number (the professor considers the first term in which he taught the course to be term 1 and so on), a test number, the number of students attempting the test and the number of students who were able to produce a working program. A short part of this file is shown below. 1
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/07/2010 for the course ECOR 1606 taught by Professor John bryant during the Fall '09 term at Carleton CA.

### Page1 / 5

oldexamquestions - Question 2 This question involves a...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online