Home / Questions / What is the result stored in x, after evaluating the following expression?Given: int x = 5; Expression: x++ * 2 + 3 * --x;
Explanatory Question

What is the result stored in x, after evaluating the following expression?

Given: int x = 5;

Expression: x++ * 2 + 3 * --x;

👁 122 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Answer: The expression evaluates as follows:

  • x++ returns 5 and then increments x to 6.
  • --x decrements x back to 5 and returns 5.
  • Therefore, the expression becomes: 5 * 2 + 3 * 5 = 10 + 15 = 25.

Hence, the result stored in x is 25.