2004 winter final

Report 0 Downloads 110 Views
McGill University Computers in Engineering CS208A Winter Semester 2004 Final Examination VERSION --- A 9:00 AM to 12:00 Noon, April 23, 2004

Examiners: Professor M. Newborn and Mr. O. Giroux Associate Examiner: Professor G. Ratzer

Calculators are allowed -- but if you find you need one, you have made a mistake! Answer directly on this exam paper. Not all questions have the same weight, but the exam adds up to 100 marks. Page 2 of this exam gives a summary of the credit assigned to each question and an estimate of the time to answer. Some questions have several parts. Questions that are answered Yes/No or True/False are graded based on the number that are correct. You can obtain up to 3 bonus points for answering Question 41 or 42, but you can answer only one of the two questions.

2 Summary of Grading: Question

Marks

Approx. Time

1

2

2

Your Marks

Question

Marks

Approx. Time

2

21

1

2

2

2

22

1

2

3

1

1

23

1

2

4

2

2

24

1

2

5

1

1

25

2

4

6

2

2

26

2

4

7

1

1

27

2

4

8

2

2

28

2

3

9

2

2

29

2

3

10

1

1

30

2

3

11

4

6

31

2

4

12

3

6

32

2

4

13

2

3

33

2

4

14

2

6

34

2

4

15

2

3

35

2

4

16

2

3

36

2

4

17

2

2

37

3

6

18

2

2

38

2

4

19

1

2

39-1

20

20

20

1

2

40-1

7

15

40-2

3

10

Exam Total

100

160 minutes

Bonus

3

Final Total

103

1. (2 marks) Determine the value of the FORTRAN expression shown here:

Your Marks

3 var = (1/2)*1.0 + (1-3)*(4**(1**9+1**9/2**4)) A) -7.5 B) -8 C) -8.224061 D) 0.5 E) None of the above

2. (2 marks) What does this FORTRAN program output? PROGRAM CHAR IMPLICIT NONE INTEGER :: e, B CHARACTER*1 :: A e A E B

= = = =

4 "e" 8 e

PRINT*, A, e, E, "A", B STOP END PROGRAM A) 448e4 B) e48A4 C) e88A8 D) A48e4 E) None of the above

4

3. (1 mark) Comments can be used in C programs. There are two general ways to comment code. One of them is to: A) Place comments before the two characters “//” which are the last characters on a line. B) Place comments anywhere so long as they begin with the two characters “//” and end with the two characters “//”. C) Place comments following “/*” which are the first two characters on a line. D) Place comments anywhere so long as they begin with the two characters “/*” and end with the two characters “/*”. E) None of the above

4. (2 marks) The main reason for including header files in a C program is to: A) make the program run faster. B) make the program easier to debug. C) allow calls to functions in libraries. D) allow the program to run on a variety of computers. E) allow recursive functions.

5

5. (1 marks) Because C was designed for very large software projects, it comes equipped with a very powerful function system which favors code re-use through libraries. These are accessed by using headers, which contain definitions of the functions made available, called... A) function declarations. B) function prototypes. C) function pointers. D) function helpers. E) None of the above

6. (2 marks) In a C program, the “continue” statement is normally used in conjuction with the following “key” words (Answer True or False): A) fscanf

____________

B) do

____________

C) fprinf

____________

D) for

____________

6

7. (1 mark) How many bytes are there in the C array A defined by the statement: int A[3][2][2]; A) 9 B) 24 C) 48 D) 96 E) None of the above

8. (2 marks) Indicate (by Yes or No) which of the following are valid function prototypes in a C program? A) void func(void);

___________

B) void long func(a,b);

___________

C) char func(int,int);

___________

D) double func(double *a, double *b);

___________

E) double(*func)(int,int);

___________

F) int func();

___________

7

9. (2 marks) The C function rand() returns: A) a real number in the range from 0 to 1 B) an “int” in the range from 0 to +32767 C) an integer in the range from –16383 to +16383 D) a number that depends on the time of day E) None of the above

10. (1 mark) The srand( ) function in C requires the inclusion of which header file? A) stdio.h B) stdlib.h C) math.h D) string.h E) Another header file not named above

8

11. (4 marks) Suppose the following code is in a C program, what are the decimal values of C, D, E, and F after these statements are performed? A = 17; B = 21; C = A & B; D = (A
Recommend Documents