- 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
5 odpowiedzi
+ 3
You don't seem to have any such reference to a code anywhere on your profile.
Please send here.
+ 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
+ 1
Khang's post mean
I = 0, result = 0
I = 1, result = 0 + 1 = 1
...
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