What is the output of this code? int var1=5; int var2=6; int var3; var3 =++var2*var1 /var2+var2; System.out.print(var3); How is the answer to this 12. Thank you.
1/11/2018 11:44:58 AM
Amit Gupta3 Answers
New Answeryeah, classic gotcha!, good answer HK. It is always tempting to add the numbers together first then use division. But in maths there is operator precedence so *and / get processed before + and -.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message