- 2

Why answer 17

Int result =0; For (int i=0;i<5;i++){ If (i==3){ Result +=10; } else{ Result+=i; } } System.out.println(result); Why answer 17 explain me now

1st Jul 2019, 2:20 PM
Balaji.V
Balaji.V - avatar
5 Antworten
+ 3
You don't seem to have any such reference to a code anywhere on your profile. Please send here.
1st Jul 2019, 3:32 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Int result =0; For (int i=0;i<5;i++){ If (i==3){ Result +=10; } else { Result+=i; } } System.out.println(result); Why answer 17 explain me now
1st Jul 2019, 3:43 PM
Balaji.V
Balaji.V - avatar
+ 1
Khang's post mean I = 0, result = 0 I = 1, result = 0 + 1 = 1 ...
1st Jul 2019, 5:46 PM
zemiak
0
I = 0 > result = 0 I = 1 > result = 0 + 1 = 1 I = 2 > result = 1 + 2 = 3 I = 3 > result = 3 + 10 = 13 I = 4 > result = 13 + 4 = 17
1st Jul 2019, 4:17 PM
khangnd
khangnd - avatar