APSC 2007 final

APSC 2007 final - DO NOT REMOVE STAPLE! THE UNIVERSITY OF...

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

View Full Document Right Arrow Icon
THE UNIVERSITY OF BRITISH COLUMBIA APSC 160: FINAL EXAMINATION A PRIL 24 TH , 2007 Name: _______________________ Student #: _________________ Signature: _____________________ Section (circle one): 203 (pm) 204 (am) Question Mark Max 1 7 2 5 3 9 4 9 5 9 6 21 7 6 8 6 9 9 10 19 Total 100 Rules Governing Formal Examinations 1. Each candidate must be prepared to produce, upon request, a Library/AMS card for identification. 2. Candidates are not permitted to ask questions of the invigilators, except in cases of supposed errors or ambiguities in examination questions. 3. No candidate shall be permitted to enter the examination room after the expiration of one-half hour from the scheduled starting time, or to leave during the first half hour of the examination. 4. Candidates suspected of any of the following, or similar, dishonest practices shall be immediately dismissed from the examination and shall be liable to disciplinary action. a. Having at the place of writing any books, papers or memoranda, calculators, computers, audio or video cassette players or other memory aid devices, other than those authorized by the examiners. b. Speaking or communicating with other candidates. c. Purposely exposing written papers to the view of other candidates. The plea of accident or forgetfulness shall not be received. 5. Candidates must not destroy or mutilate any examination material; must hand in all examination papers; and must not take any examination material from the examination room without permission of the invigilator. Notes about this examination 1. You have 2 hours and 30 minutes to write this examination. 2. No notes, books, or any type of electronic equipment is allowed including cell phones and calculators. 3. In the interests of time, it is not necessary to include comment statements in your code. 4. Good luck! DO NOT REMOVE STAPLE!
Background image of page 1

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

View Full DocumentRight Arrow Icon
Page 2 of 19 [7] Q1. For each of the multiple choice questions below, circle the one best answer . Q1A. What does a C language compiler do? a) translate from C into machine language b) verify correctness of a program c) process directives like #include and #define before running the program d) organize all the C program files in a directory Q1B. Which is the correct way to declare a variable s containing the string foo ? a) char s = ’foo’; b) char s = ”foo”; c) char s[] = ”foo”; d) char s[] = foo\0; Q1C. After the following lines of code execute, what is the value of k? int i = -1; int k = i++; a) 0 b) 1 c) -1 d) garbage Q1D. Which of the following expressions is always TRUE? Assume p is an int variable. a) p || !p b) p && !p c) !p || !p d) p && p Q1E. A global variable a) is accessible to any function that wants to use it b) is initialized every time a function is called c) can not be changed d) allows faster access than a normal variable Q1F. Character variables in C are passed to functions a) by name b) by reference c) by value d) as strings Q1G. An unsigned char can take values between (and including) a) -128 and 127 b) 0 and 1024 c) ’a’ and ‘Z’ d) 0 and 255
Background image of page 2
Page 3 of 19 [5] Q2. Consider the following code segment: #define TRUE 1 int i=0; int k=5; int arr[] = {0,-1,23,6,5,9,-43}; while(TRUE) { if(arr[i]==k) { printf(“Found %d at location %d in array\n”,k,i); break; } else {
Background image of page 3

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

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

Page1 / 19

APSC 2007 final - DO NOT REMOVE STAPLE! THE UNIVERSITY OF...

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

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