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; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

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;

tell me output.

27th Nov 2017, 3:26 AM
Madhuri Bhamare
4 Answers
+ 5
Why not you run the code on Code Playground?
27th Nov 2017, 3:36 AM
blackcat1111
blackcat1111 - avatar
+ 4
Technically, there is no output. But if you add the line: Console.WriteLine(result) then it would be 17. Unless I'm mistaken, of course. 😉
27th Nov 2017, 5:35 AM
blackcat1111
blackcat1111 - avatar
+ 3
37 if I not wrong
27th Nov 2017, 3:33 AM
Momo Belia
Momo Belia - avatar
+ 1
the answer is 17! why is it 37???
27th Nov 2017, 5:14 AM
David Fernando
David Fernando - avatar