0
Why is the output 17 ? (this is the array modul quiz(SoloLearn)) int result = 0; for (int i = 0; i < 5; i++){ if (i == 3) { result += 10; }else{ result += i; } } System.out.println (result);
5 Réponses
+ 1
check the for loop, variable "result" is added everytime with the I value and added by 10 when value of I is 3. so each time loop runs the value of result changes. 0+1+2+10+4=17.
0
never mind, got it;)
0
can you explain?
0
resultv= result + i
i=0
result=0
i=1
result=1
i=2
result=3
i=3
result=13
i=4
result=17
0
it be 17