2025-02-20 23:51:20 +01:00
..
2025-02-20 23:51:20 +01:00
2025-02-20 23:51:20 +01:00

Task

Let a, b, c, and d be variables of type int.

  • Which of the following character sequences are valid expressions in the sense that they are accepted by a C++ Compiler? Explain your answer.
  1. a = b = 5
  2. 1 = a
  3. ++a + b++
  4. a + b = c + d
  5. a = 2 b

Assume that all the variables have been defined and correctly initialized and that all expressions are completely independent from each other.

  • For each of the expressions that you have identified as valid, decide whether the entire expression is an lvalue or an rvalue, and explain your decision.

  • Determine the values of the expressions that you have identified as valid and explain how these values are obtained.