What datatype is the expression vat0at0at0 a char b

Info icon This preview shows pages 9–12. Sign up to view the full content.

View Full Document Right Arrow Icon
What datatype is the expression: v.at(0).at(0).at(0) A) char B) vector <string> C) string D) vector <vector <string> > 46) The function max (Code block 18), will return the maximum of two values. Which of the function calls will help discover a logic error within the function? A) max(3, 3) B) max(4, 3) C) max() D) max(2, 3) 47) What is stored in the vector after the code block 17 executes? A) 6 3 1 B) 6 3 1 4 C) the vector is empty D) 6 3 E) 6 3 1 4 3 F) the loop never finishes (infinite loop) 48) What is output by Code Block 19? A) runtime error B) hh2s2 C) h2s2 D) hpqms 49) The program shown contains a loop that could be packaged as a function. Which of the following function prototypes would best accomplish this? (keep in mind the "best practices" we use in class). int main() { // ... string reply; while (reply != "yes" && reply != "no") { cout << "Continue (answer yes or no)? "; cin >> reply; } // ... } A) void getReply ( const string & ); B) void getReply ( string ); C) string getReply ( string & ); D) string getReply ( string ); E) string getReply(); F) void getReply ( string & );
Image of page 9

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

View Full Document Right Arrow Icon
Name (first and last): _________________________________ Username: ______________ Code Block 20 Code Block 21 bool q(int x, int y) { x = x - y; return x > y; } int main() { int a = 3; int b = 1; bool m; m = q(a, 4); // Line 1 m = q(a, b); // Line 2 return 0; } bool f(int &a, int b) { a = a * b; return a > b; } int main() { int a = 5; int b = 3; f(a, b); // 1 f(5, b); // 2 f(a, 3); // 3 f(&a, 3); // 4 return 0; } 50) Given the code block 21, which of the function calls in main would be valid? A) 1 and 3 B) 1 C) 3 D) 1, 2, and 3 E) 1, 2, 3, and 4 F) none 51) In the code block 20, what is assigned into m on line 1? A) true B) false 52) In the code block 20, what is assigned into m on line 2? A) true B) false 53) What will be the final value of count? int count = 0; for (int i = 0; i < 5; ++i) { for (int j = 0; j < i; ++j) { ++count; } } cout << count; A) 0 B) 5 C) 10 D) 11 E) 15 F) 25
Image of page 10
Name (first and last): _________________________________ Username: ______________ Scratch Paper (must be turned in with exam)
Image of page 11

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

View Full Document Right Arrow Icon
Name (first and last): _________________________________ Username: ______________ Scratch Paper (must be turned in with exam)
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern