1-----key1_06f[1]

1-----key1_06f[1] - Exam 1, 10/23/05 PIC 10A, Fall 2006 KEY...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 Exam 1, 10/23/05 PIC 10A, Fall 2006 KEY _____ Pascal _____ Nick 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 100 points on this exam. PROBLEM SCORE 1 2 3 4 5 TOTAL T 1.) [12 points] Correct the error(s) in each of the code segments below. a.) int x = 1 while ( x < 10 ) cout << x x ++ Need the braces. while ( x < 10 ) { } b.) if ( response = "yes" or "YES" ) cout << "You said yes." if ( response == "yes" || response == "YES" ) Check your TAhs name:
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 c.) if ( 1 < x < 5 ) cout << x if ( x > 1 && x < 5 ) d.) double investment = 2000.0 double return = 1.016 * investment cout << "The return on your investment of $" << investment << " is $" << return Can't use return as a variable name. double my_return = 1.016 * investment cout << . .. << my_return c 2.) [20 points] Write the output of the following segments of code.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/21/2008 for the course PIC 10A taught by Professor Wittman during the Spring '08 term at UCLA.

Page1 / 10

1-----key1_06f[1] - Exam 1, 10/23/05 PIC 10A, Fall 2006 KEY...

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

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