English

What is the value of x after evaluating: x + = x + + + - - x + 4; if x = 3, before the evaluation?

Advertisements

Question

What is the value of x after evaluating:

x + = x + + + - - x + 4; if x = 3, 

before the evaluation?

Evaluate
Advertisements

Solution

Initial value of x = 3

x + = x + + + - - x + 4;

Step 1: The initial value of x is 3.

Step 2: x++ uses the value 3 and then increments x to 4.

Step 3: --x decreases the value of x from 4 to 3 and uses 3.

Step 4: Evaluate the right-hand side:

3 + 3 + 4 = 10

Step 5: The += operator adds the result to the original value of x.

x = 3 + 10 =13
x = 13
shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Variables and Expressions - EXERCISE [Page 132]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 33. | Page 132
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×