Embercode
✕
C++ Functions and ScopeQuick quiz

Returns

6 questions. Covers Returning multiple values.

Questions 1 to 5 of 6

  1. 1. Which standard type holds exactly two values, and lets those two values have different types?
  2. 2. A caller meant divide_out(17, 5, quo, rem); but wrote divide_out(17, 5, rem, quo);. Why does the compiler accept this without an error?
  3. 3. Structured bindings, such as auto [q, r] = divide_with_remainder(17, 5);, were added to C++ in version ___. Answer with the number only.

    Type your answer.

  4. 4. The standard function that assigns a tuple's parts to variables that already exist is std::___. std::ignore can be used with it to skip one part.

    Type your answer.

  5. 5. What does this program print? ``cpp #include <iostream> #include <tuple> std::tuple<int, int> divide_with_remainder(int a, int b) { return {a / b, a % b}; } int main() { auto t = divide_with_remainder(29, 6); std::cout << std::get<0>(t) << " " << std::get<1>(t) << '\n'; auto [q, r] = divide_with_remainder(29, 6); std::cout << r * 10 + q << '\n'; } ``

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.