F09_10A_key2

# F09_10A_key2 - Exam 2 PIC 10A Fall 2009 KEY Check your...

This preview shows pages 1–3. Sign up to view the full content.

Exam 2, 11/23/09 PIC 10A, Fall 2009 KEY Check your discussion section: _____ 2A Kree 1:00 _____ 2B Brian 11:00 _____ 2C Alejandro 12:00 _____ 2D Jacob 12:00 You have 50 minutes 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 50 points on this exam. PAGE SCORE POSSIBLE 1 11 2 6 3 4 4 9 5 10 6 10 TOTAL 50

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

View Full Document
1 1.) [5 points] Write a block of code (not a full program) that creates a vector v and fills it with the first 100 multiples of 3. 3 6 9 12 15 18 21 24 ..... 297 300 vector<int> v(100); for (int i=0; i<100; i++) v[i] = 3*(i+1); 2.) [6 points] Correct the error in the following blocks of code. a.) vector<int> v(100); for (int j=0; j<=100; j++) v[i] = i*i; There are 2 errors: the variables i,j have been mixed up and the loop runs off the end of the vector. for (int j=0; j<100; j++)
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 Spring '10 term at UCLA.

### Page1 / 7

F09_10A_key2 - Exam 2 PIC 10A Fall 2009 KEY Check your...

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

View Full Document
Ask a homework question - tutors are online