{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

mf08b-1

# mf08b-1 - Last Name First Name McGill ID McGill University...

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

Last Name _____________________________________ First Name _____________________________________ McGill ID ______________________________________ McGill University COMP 208 -- Computers in Engineering Second Mid-Term Examination Tuesday, November 11, 2008 2:35 – 4:00 P. M. Grading: Question Possible Points Your Grade 1 15 marks 2 35 marks Total 50 Computers in Engineering 1 of 5 November 11, 2008 Second Midterm test

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

View Full Document
Question 1 Consider the following code that computes the maximum value in an array. program midterm implicit none integer :: i, A(100) read (*,*) (A(i), i=1, 100) write (*,*) “The maximum value is “, maximum(A) end program midterm integer function maximum(A) implicit none integer :: A(100) integer :: i, big = A(1) do i = 2, 100 if (A(i)>big) big=A(i) end do maximum = big end function maximum Now suppose you want to compute both the maximum and minimum values in an array. Rather than writing two functions that scan the array twice, you decide to use a single subprogram that returns both the maximum and minimum values. Of course you will no longer be able to use a function to return two values. (a) (10 marks) Write a subroutine definition called MAX_AND_MIN. This subroutine should make one pass through the array and calculate both the maximum and minimum values. They should be
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

mf08b-1 - Last Name First Name McGill ID McGill University...

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

View Full Document
Ask a homework question - tutors are online