+ 1

Can anybody explain how 12 is coming?

import java.util.*; class solo{ public static void main(String[] args){ int v1=5; int v2=6; int v3=++v2*v1/v2+v2; System.out.println(v3); } }

4th May 2019, 3:33 AM
vishal agrawal
vishal agrawal - avatar
2 Réponses
+ 1
kiRA thanks😊
4th May 2019, 4:27 AM
vishal agrawal
vishal agrawal - avatar
0
++ has highest precedence so v2 = 7 * and / have same precedence so first * will be evaluated then / v3 = 7*5/7 +7 v3= 35/7 +7 v3 = 5+7 = 12
4th May 2019, 3:43 AM
kiRA
kiRA - avatar