int x = 5 ; x = (x++)*2+3+(--x) System.out.println(x); answer is 18 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

int x = 5 ; x = (x++)*2+3+(--x) System.out.println(x); answer is 18

please explain this question.but my answer is coming 19 bcz (--x) should be 4 as it is post decreement

25th Sep 2020, 12:58 PM
Ali Xd Rocks
Ali Xd Rocks - avatar
3 Answers
+ 3
x=5*2+3+5 =10+3+5=18 x++ increments the value afterwards, so x becomes 6 from 5 and then --x decreases it and it becomes 5 again
25th Sep 2020, 1:03 PM
Abhay
Abhay - avatar
+ 1
thanks
25th Sep 2020, 1:08 PM
Ali Xd Rocks
Ali Xd Rocks - avatar
0
.Q3. Give the output of the following snippet: 1) int x=5; Find x = x++ *2+3*x;
27th Feb 2024, 10:25 AM
pramod agrawal
pramod agrawal - avatar