+ 1

Help needed

Int a=4; Int b=8; If((b-a--) >=0) If((b+a)%2==1) System.out.println(a*b); else System.out.println (b+a); Can anyone explain how the answer to this is 24? Thanks.

11th Jan 2018, 11:12 AM
Amit Gupta
Amit Gupta - avatar
4 Respostas
+ 3
4>0 then 8+3 % 2 == 1 so output is 3*8 = 24
11th Jan 2018, 11:23 AM
shobhit
shobhit - avatar
+ 2
Thanks man
11th Jan 2018, 11:26 AM
Amit Gupta
Amit Gupta - avatar
+ 2
The value of a is changed to 3 in the third line isn't it? Don't we need to do something like a=a-- for that to happen?
11th Jan 2018, 11:28 AM
Amit Gupta
Amit Gupta - avatar
0
a-- means a=a-1
11th Jan 2018, 2:18 PM
shobhit
shobhit - avatar