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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online