0 day streak
c / beginner
Snippet

The do-while Loop

The do-while loop ensures that the code block inside 'do' is executed at least once before the condition is checked.

snippet.c
c
1
int status = 0; do { status = 1; } while (status == 0);
Breakdown
1
do { ... }
Defines the block of code to be executed.
2
while (status == 0);
Checks the condition. The loop ends if status is no longer 0.