0
What is the output of this code? int result = 0; for (int i = 0; i < 5; i++) { if (i == 3) { result += 10; } else {
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);
4 ответов
+ 3
17
checked with my netbeans lol
when i = 0, result = 0
when i = 1, result = 1
when i = 2, result = 3
when i = 3, result = 13
when i = 4, result = 17
i can only reach 4 because i < 5
+ 1
17
0
yeah that's what i arrived at too (result=17)
0
17