C Loop Statements
This chapter introduces three types of loops: for, while, do-while, as well as the usage and considerations of break/continue.
1. for Loop
- Suitable for loops with known iteration count
2. while Loop
- Suitable for condition-driven loops
3. do-while Loop
- Executes at least once
4. break and continue
break: Immediately ends the current loopcontinue: Skips the remaining part of the current iteration and enters the next iteration
5. Multi-level Nesting and Performance
- Try to avoid deep nesting, consider splitting into functions
- Be aware of expensive operations inside loops (like I/O)