PIC10AfinalF09

PIC10AfinalF09 - Final Exam PIC 10A Fall 2009 NAME ID Check...

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

View Full Document Right Arrow Icon
Final Exam, 12/6/09 PIC 10A, Fall 2009 NAME: _________________________________________________ ID#: ____________________________________________________ Check your discussion section: _____ 2A Kree 1:00 _____ 2B Brian 11:00 _____ 2C Alejandro 12:00 _____ 2D Jacob 12:00 You have 3 hours to complete this exam. You are not allowed to use any books, notes, calculators, or electronic devices. Write your answers carefully. Incomplete, unintelligible, or illegible answers will receive little or no credit. When you are asked to write a program, it is not necessary to comment your code but you are expected to indent appropriately to make your code easier to follow. There are a total of 100 points on this exam. PAGE SCORE POSSIBLE 1 6 2 6 3 12 4 6 5 5 6 14 7 8 8 10 9-10 15 11-12 18 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 1.) [4 points] We taught both vectors and arrays in this course and we discussed the relative advantages of each. a.) Give a situation in which it would be better to use a vector instead of an array. Explain briefly why the vector is better. b.) Give a situation in which it would be better to use an array instead of a vector. Explain briefly why the array is better. 2.) [2 points] In HW7 and HW8, you used a Card class whose constructor created a card with a random rank and suit. Explain why it is a bad idea to seed the random number generator with the srand function inside the Card constructor.
Background image of page 2
2 3.) [6 points] Each of the code segments below contains an error. Explain what the error is and then correct the error. a.) string old, new; cout << "Enter the old name: "; getline(cin, old); cout << "Enter the new name: "; getline(cin,new); cout << old << " became " << new; b.) vector<string> names(10); for (int i=0; i<=10; i++) { cout << "Enter a name: "; cin >> names[i]; } c.) char c; cout << "Enter a letter: "; cin >> c; char* p = c; *p = 'Q'; cout << c;
Background image of page 3

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

View Full DocumentRight Arrow Icon
3 4.) [12 points] Write the output of the following blocks of code. a.)
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 04/27/2010 for the course PIC 157-050-20 taught by Professor Wittman during the Winter '10 term at UCLA.

Page1 / 13

PIC10AfinalF09 - Final Exam PIC 10A Fall 2009 NAME ID Check...

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