[SOLVED] Explain the small problem in c# | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[SOLVED] Explain the small problem in c#

Here it is: int i; for(i = 0; i < 15; i += 7) {} Console.Write(i) why output of this code is 21 ?

23rd Sep 2020, 2:34 PM
Wiktor Kalaga
2 Answers
+ 3
The loop goes: i = 0 ; 0 < 15 //true i += 7 i = 7 ; 7 < 15 //true i += 7 i = 14 ; 14 < 15 //true i += 7 i = 21 ; 21 < 15 //false Loop ends. i is 21.
23rd Sep 2020, 2:38 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
CarrieForle thank you for the explanation !
23rd Sep 2020, 2:44 PM
Wiktor Kalaga