Embercode
✕
C++ OperatorsQuick quiz

Evaluation order and precedence

8 questions. Covers Precedence trees.

Questions 1 to 5 of 8

  1. 1. Predict the output of this program. ``cpp #include <iostream> using namespace std; int main() { int n = 4; int r = n-- - 1; cout << n << ' ' << r << endl; return 0; } ``
  2. 2. What is wrong with this code? ``cpp int j = 1; int s = j++ + j++; ``
  3. 3. In C++17 and later, which side of a = b is evaluated first?
  4. 4. Predict the output of this program. ``cpp #include <iostream> using namespace std; int main() { int x = 7 - 3 - 2; int y = 2 * 3 << 1; cout << x << ' ' << y << endl; return 0; } ``
  5. 5. True or false: in C++, 2 - 3 - 4 groups as 2 - (3 - 4).

5 question(s) left on this page.