Loops in C
From the C cheat sheet · Control Flow · verified Jul 2026
Loops
for, while, do-while, and jumps.
c
// Quick Reference
for (int i = 0; i < 5; i++) { ... }
while (cond) { ... }
do { ... } while (cond);
break; continue;💡 Declaring the loop variable in the for header (for (int i...)) scopes it to the loop (C99+).
⚡ do-while always runs its body once before checking the condition.
📌 break leaves the loop; continue jumps to the next iteration.
🟢 goto is discouraged generally, but a single-exit "goto cleanup" is a common C idiom.
loopsgoto