{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

2005%20Fall%20midterm

2005%20Fall%20midterm - Last Name First Name McGill ID...

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

View Full Document Right Arrow Icon
Last Name _____________________________________ First Name _____________________________________ McGill ID ______________________________________ McGill University Computers in Engineering COMP-208A Mid-Term Examination Tuesday October 11, 2005 2:35 – 4:00 P. M. Faculty calculators allowed. All programs below have been tested and run without errors. Grading: Question Possible Points Your Grade 1 0 2 0 3 2 4 2 5 2 6 2 7 2 8 7 9 6 10 6 11 6 12 6 13 6 14 6 15 6 16 6 17 35 Total 100 Computers in Engineering 1 of 10 October 11, 2005 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 Document Right Arrow Icon
Computers in Engineering 2 of 10 October 11, 2005 Midterm test Version 1
Background image of page 2
Question 1 There are multiple versions of this test. This is version 1. On the scoring sheet mark A. 1 << This is version 1 B. 2 C. 3 D. None of the above Question 2 There are two sections of this course being taught. Which section have you attended the majority of the times? Question 3 Source code, written in some computer language like Fortran, is a human readable text file that will be translated into machine code by a compiler so that the computer may execute the instructions given to it. True or False? Question 4 In Fortran, a variable is a place where a program can store information. Once declared a single variable can hold any type of data, for example the same variable could hold a real number at one point in the program and then a character later on in the program. True or False? Question 5 A conditional statement, like Fortran's IF THEN ELSE construct, allows a program to do the same thing over and over again. For example, such a statement could, by itself, count from 1 to 100. True or False? Question 6 In Fortran, the == operator is used for comparison between the left-hand and right-hand operands and returns a logical value (either .TRUE. or .FALSE.), whereas the = operator is used for assignment of the right-hand operand into the variable in the left-hand operand. True or False? Question 7 What is the result of the expression 5/3 == 4/3 True or False? Computers in Engineering 3 of 10 October 11, 2005 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 Document Right Arrow Icon
Question 8 What is the output of the following program? PROGRAM mid1 IMPLICIT NONE INTEGER :: L=4132 INTEGER :: Answer WRITE (*,*) Answer(Answer(L,1),3) END PROGRAM mid1 INTEGER FUNCTION Answer(N,D) INTEGER, INTENT(IN) :: N, D INTEGER :: TempN, TempD, Dcount, NewN NewN = 0 Dcount = 0 TempN = N DO IF (TempN<=0) EXIT TempD = MOD(TempN,10) TempN = TempN/10 IF (TempD /= D) THEN Dcount = Dcount + 1 NewN = NewN + TempD*(10**(Dcount-1)) END IF END DO Answer = NewN END FUNCTION Answer
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}