# Loops — C Programming

Source: https://www.geekswithgeeks.com/en/c/c-loops

> Repeat a block while a condition holds.

## while / do-while / for

`do ... while` runs the body at least once. `for` is best when you know the count.

```c
for (int i = 1; i <= 5; i++) {
    printf("%d ", i);
}
// 1 2 3 4 5
```

Output:

```
1 2 3 4 5
```

## break & continue

`break` exits the loop entirely. `continue` skips to the next iteration.

**Quiz:** Which loop always runs its body at least once?

- [ ] while
- [ ] for
- [x] do ... while

*Answer:* do ... while. do ... while checks its condition after the body.
