What will be the output if: int x=5 and x++*2+3*- -x | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What will be the output if: int x=5 and x++*2+3*- -x

Please explain stepwise

1st Feb 2022, 7:18 AM
ANU
2 Answers
+ 1
Is that --x or - -x ? The former had no space between the dash The latter had a space between the dashes ...
1st Feb 2022, 7:50 AM
Ipang
+ 1
There appears to be a difference in output when --x was used and when - -x was used. I'm not sure which one is being asked for ... int x = 5; int y = x++ * 2 + 3 * - -x; // - -x System.out.println( y ); // output 28 x = 5; // reset <x> back to 5 y = x++ * 2 + 3 * --x; // --x System.out.println( y ); // output 25
1st Feb 2022, 8:18 AM
Ipang