exam1key - Exam 1, 10/23/05 PIC 10A, Fall 2006 KEY Check...

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

View Full Document Right Arrow Icon
Exam 1, 10/23/05 PIC 10A, Fall 2006 KEY Check your TA’s name: _____ 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
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.) [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" ) 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;
Background image of page 2
2.) [20 points] Write the output of the following segments of code. a.)
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 / 6

exam1key - Exam 1, 10/23/05 PIC 10A, Fall 2006 KEY Check...

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