quiz5_sol - CS 010 Intro to Computer Science I Spring -...

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

View Full Document Right Arrow Icon
CS 010 – Intro to Computer Science I Spring - 2008 Quiz 5 – Friday 5/9 SOLUTION 1. Which of the following statements will extract the last letter of the string variable name as a char value? a. string last = name.substr( name.length() ); b. char last = name.substr( name.length() ); c. string last = name.substr( name.length() - 1 ); d. char last = name.substr( name.length() - 1 ); e. char last = name[ name.length() ]; f. char last = name[ name.length() - 1 ]; 2. Which of the following statements correctly constructs a Time object from the text-supplied Time class? (Given that dinner and eleven_pm are valid, initialized Time objects) a. Time breakfast = now(); b. Time lunch(12, 15); c. Time dinner = (17, 30, 0); d. Time late_snack = eleven_pm; e. Time now(); f. b) and d) are correct 3. What will be output by the following code fragment? int n = 1; while (n <= 10) { if (n % 3 != 0) { cout << n << " "; } ++n; } cout << n << endl; a. 11 b. 10 c. 3 6 9 d. 3 6 9 10 e. 1 2 4 5 7 8 10 11 f. 1 2 4 5 7 8 10
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/05/2008 for the course CS 010 taught by Professor Linard during the Spring '08 term at UC Riverside.

Page1 / 2

quiz5_sol - CS 010 Intro to Computer Science I Spring -...

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

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