fa10ex1 - University of Illinois at Urbana-Champaign...

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

View Full Document Right Arrow Icon
University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Fall 2010 7p-9p, Tuesday, September 28 Name: NetID: Lab Section (Day/Time): This is a closed book and closed notes exam. No electronic aids are allowed, either. You should have 5 problems total on 20 pages. The last two sheets are scratch paper; you may detach them while taking the exam, but must turn them in with the exam when you leave. Unless otherwise stated in a problem, assume the best possible design of a particular imple- mentation is being used. Unless the problem specifically says otherwise, (1) assume the code compiles, and thus any compiler error is an exam typo (though hopefully there are not any typos), and (2) assume you are NOT allowed to write any helper methods to help solve the problem, nor are you allowed to use additional arrays, lists, or other collection data structures unless we have said you can. We will be grading your code by first reading your comments to see if your plan is good, and then reading the code to make sure it does exactly what the comments promise. In general, complete and accurate comments will be worth approximately 30% of the points on any coding problem. Please put your name at the top of each page. Problem Points Score Grader 1 20 2 20 3 20 4 20 5 20 Total 100
Background image of page 1

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

View Full DocumentRight Arrow Icon
1. [Pointers, Parameters, and Miscellany – 20 points]. MC1 (2.5pts) Consider the following statements, and assume the standard iostream library has been in- cluded: int v; int * w; v = 10; w = v; *w = 8; cout << v << endl; What is the result of executing these statements? (a) 8 is sent to standard out. (b) 10 is sent to standard out. (c) This code does not compile. (d) This code results in a runtime error. (e) None of these options is correct. MC2 (2.5pts) Consider the following statements, and assume the standard iostream library has been in- cluded: int b; int * a = new int(8); b = *a; *a = 10; cout << b << endl; delete b; What is the result of executing these statements? (a) 8 is sent to standard out. (b) 10 is sent to standard out. (c) This code does not compile. (d) This code results in a runtime error. (e) None of these options is correct.
Background image of page 2
MC3 (2.5pts) What is the output of the following sequence of C++ statements? (The sphere class interface is included at end of the exam.) sphere * a, * b; a = new sphere(1.0); b = a; b->setRadius(2.0); delete b; a->setRadius(4.0); sphere * c = new sphere(5.0); b = new sphere(3.0); cout << a->getRadius() << endl; (a) 4.0 (b) 3.0 (c) A segmentation fault. (d) Compiler error. (e) The behavior cannot be predicted.
Background image of page 3

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

View Full DocumentRight Arrow Icon
MC4 (2.5pts) Consider the following statements, and assume the standard iostream library has been in- cluded: void doub(int x) { x = x * 2;} void trip(int * x) { *x = *x * 3; } void quin(int & x) { x = x * 5; } int main() { int x = 1; doub(x); trip(&x); quin(x); cout << x << endl; return 0; } What is the result of executing these statements? (a) 1 is sent to standard out.
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.

This note was uploaded on 08/25/2011 for the course CS 225 taught by Professor Ttt during the Spring '08 term at University of Illinois at Urbana–Champaign.

Page1 / 20

fa10ex1 - University of Illinois at Urbana-Champaign...

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

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