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 ?
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.
0
CarrieForle thank you for the explanation !