master
Miloslav Ciz 2 years ago
parent 21b462954a
commit 4f4dedf443

@ -248,7 +248,7 @@ Counting until 5...
IMPORTANT NOTE: in programming we **count from 0**, not from 1 (this is convenient e.g. in regards to [pointers](pointer.md)). So if we count to 5, we get 0, 1, 2, 3, 4. This is why `i` starts with value 0 and the end condition is `i < 10` (not `i <= 10`).
Generally if we want to repeat the `for` loop *N* times, the format is `for` loop is for `(int i = 0; i < N; ++i)`.
Generally if we want to repeat the `for` loop *N* times, the format is `for (int i = 0; i < N; ++i)`.
Any loop can be exited at any time with a special command called `break`. This is often used with so called infinite loop, a *while* loop that has `1` as a condition; recall that 1 means true, i.e. the loop condition always holds and the loop never ends. `break` allows us to place conditions in the middle of the loop and into multiple places. E.g.:

Loading…
Cancel
Save