What will be value of x if a=2 and b=4 int x=++a+b++
Answers
Answered by
1
Answer:
x=++a+ b++
x=3+4
x=7
Additional information:
In ++a the value is first incremented then assigned. It is also called Change before action. In the above problem value first gets incremented I.e. 3 so final value of a=2 which is used there.
In a++ the value is first assigned then incremented. It is also called change after action. In the above example the value will remain the same since incremented value is not taken into consideration and the assigned value is taken I.e. 4 so final value a=4 which is used there.
Similar questions