Multiple Choice Quiz

1. Which of these numeric types is represented using the fewest bytes in C++?

2. If I created an array of strings with "std::string word_list[5000]", what should I do when I'm done using word_list?

3. You want to execute code if either var1 is true or var2 is true, but not if they are both true. Given that both variables are type bool, three of the following techniques work; which one will NOT work?

4. Which of the following is NOT a good reason a to define a member variable in the private section of a class definition?

5. What does the following line of code do?
  assert(x == 10);

6. What is a difference between a native array (such as "int a[100]") and std::vector (such as "std::vector<int> v(100)")?

7. Why should you use "include guards" (or #pragma once) in your header files?

8. Which of the following is an illegal use of the keyword "auto"?

9. What will happen if you do not explicitly initialize an int variable?

10. What will the following code output?
  std::vector<int> v{1,2,3,4};
  std::cout << std::accumulate(v.begin()+1, v.end()-1, 0) << std::endl;


Click Check Answers to identify any errors and try again. Click Show Answers if you also want to know which answer is the correct one.