c / beginner
Snippet
The do-while Loop
A do-while loop ensures that the code block is executed at least once, as the condition is checked after the execution.
snippet.c
c
1
2
3
4
int i = 10;do {i++;} while (i < 5);
Breakdown
1
do { ... }
Starts the block of code that will be executed at least once.
2
while (i < 5);
Checks the condition; if true, the loop repeats.