Embercode
✕
C++ OperatorsQuick quiz

Operator review

6 questions. Covers XOR tricks.

Questions 1 to 5 of 6

  1. 1. Match each expression to its value. Use the floor_div and floor_mod helpers from the floor division lesson, where floor_div rounds toward negative infinity and floor_mod gives a result with the sign of the divisor.

    Choose the matching item for each row.

  2. 2. Match each bit expression to what it does to a value x. Here k is a bit position.

    Choose the matching item for each row.

  3. 3. A function next_id(int& counter) adds 1 to counter and returns the new value. With int c = 0;, what does this line print in C++17 or later? ``cpp cout << next_id(c) << " " << next_id(c); ``
  4. 4. Which expression gives -4?
  5. 5. What does this program print? Each value is separated by a space. ``cpp #include <iostream> int main() { int a = -13; std::cout << a / 5 << " " << a % 5 << " " << 13 % -5 << "\n"; } ``

5 question(s) left on this page.