+ 1
problem
why the answer of this question is 17? What is the output of this code? int result = 0; for (int i = 0; i < 5; i++) { if (i == 3) { result += 10; } else { result += i; } } System.out.println(result);
2 Respuestas
+ 12
This is what happens:
i = 0: result = 0 + 0
i = 1: result = 0 + 1
i = 2: result = 1 + 2
i = 3: result = 3 + 10
i = 4: result = 13 + 4
So when the loop is finished, result is 17.
+ 1
thank you❤❤