⏭️ continue Statement in C
🔍 Short Explanation:
The continue
statement skips the current iteration of a loop and moves directly to the next iteration, bypassing the remaining code inside the loop for that cycle.
✅ Syntax
continue;
📋 Example: Continue in a for Loop
#include <stdio.h> int main() { for (int i = 1; i <= 5; i++) { if (i == 3) { continue; // skip iteration when i is 3 } printf("%d\\n", i); } return 0; }
🧠 Output: 1 2 4 5
💡 Common Use Cases
- Skipping specific values or conditions in loops
- Filtering unwanted data during iteration
- Improving readability instead of nested if-else
⚠️ Tips & Best Practices
- Use carefully to avoid infinite loops
- Do not confuse with
break
, which exits the loop entirely - Helps in cleaner and more readable loops
📌 Summary
The continue
statement is useful to skip over parts of a loop’s body under certain conditions, continuing the loop with the next iteration.