mw08 - Last Name _ First Name _ McGill ID _ Make sure the...

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

View Full Document Right Arrow Icon
Last Name _____________________________________ First Name _____________________________________ McGill ID ______________________________________ Make sure the version number is marked on your scantron sheet. This is Version 1 McGill University COMP 208 -- Computers in Engineering Mid-Term Examination Thursday, February 14, 2008 2:35 – 4:00 P. M. Faculty standard calculators allowed. Grading: Question Possible Points Your Grade 1-3 5 marks each 4-13 6 marks each 14 25 marks Total 100 Computers in Engineering 1 of 14 February 14, 2008 Midterm test Version 1
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 What is the output of the following Fortran program? PROGRAM midterm IMPLICIT NONE INTEGER :: t=1,i DO i=1,3 t=t*i END DO WRITE(*,*) t*i END PROGRAM midterm a) 4 b) 6 c) 18 d) 24 e) None of the above Question 2 How many “*”’s will be printed by the following program segment: INTEGER :: i, j, k WRITE (*,*) ((("*", k = 1, j-1), j = 1, i-1), i=1,5) a) 7 b) 10 c) 14 d) 60 e) None of the above Computers in Engineering 2 of 14 February 14, 2008 Midterm test Version 1
Background image of page 2
Question 3 What is the output of the following Fortran program? PROGRAM midterm IMPLICIT NONE INTEGER :: A,B(4),t=2,s=3,i=0,k A = s*t**s**t B(1) = s*(t**s)**t B(2) = (s*t)**s**t B(3) = s*t**(s**t) B(4) = 1 DO k=1,3 IF (A==B(k)) i=k END DO WRITE(*,*) i END PROGRAM midterm a) 0 b) 1 c) 2 d) 3 e) 4 Question 4 What is the output of the following program? program midterm implicit none integer :: a, b, c a = 78 b = 48 do c = mod(a,b) if (c==0) exit a = b b = c end do write (*,*) a, b, c end program midterm a) 6 0 0 b) 48 1 1 c) 78 48 30 d) 12 6 0 e) 12 6 2 Computers in Engineering 3 of 14 February 14, 2008 Midterm test Version 1
Background image of page 3

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

View Full DocumentRight Arrow Icon
Question 5 What is the output of the following Fortran program? program midterm implicit none integer :: I,J,K logical :: A,B,C I = 3.95 + MOD(38,4) J = 38/4*4 K = 38/4.0*4 A = J < K B = I + J == K + 2 C = .not. B .or. A WRITE (*,*) I,J,K, A, B, C end program midterm a) 6 36 38 T F F b) 5 38 38 T T F c) 5 36 2 T F T d) 5 36 38 T F T e) 5 36 2 T F F Computers in Engineering 4 of 14 February 14, 2008 Midterm test Version 1
Background image of page 4
Question 6 What is the output of the following Fortran program? PROGRAM MIDTERM
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

mw08 - Last Name _ First Name _ McGill ID _ Make sure the...

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

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