← C Programming learning path
C Programming · Module 4 of 10

Loops

Repeat with for, while and do-while loops.

📖 Key ideas

  1. for (int i = 0; i < 5; i++) repeats 5 times.
  2. while (condition) checks first; do { } while (condition); runs at least once.
  3. break exits a loop; continue skips to the next round.
  4. Nested loops are loops inside loops (patterns, tables).
  5. Be careful with infinite loops.
💡 Real-life example: A do-while loop is like tasting food before deciding to eat more: you always taste once.
forLoop with start, condition and step
do-whileLoop that runs at least once
continueSkips to the next round
i++Adds 1 to i