Table of contents
For loop2. While loop
3. do-while loop
4. Common mistakes
4.1 Infinite loops
4.2 Off-by-one errors
4.3 A loop that never runs
4.4 Array out-of-bounds access
4.6 High CPU usage (busy-wait loops)
4.7 Integer overflow in loop counter
4.8 Using uninitialized variables in loops
4.9 Modifying loop control variable inside the loop
4.10. Nested loops with high time complexity
4.11 Forgetting `break` in `switch` statements inside loops
4.12 Memory corruption
5. Final tips