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