0 day streak
c / beginner
Snippet

The while Loop

A while loop repeatedly executes its body as long as the given condition remains true (non-zero in C).

snippet.c
c
1
2
3
4
int active = 1;
while (active) {
active = 0;
}
Breakdown
1
while (active)
Starts the loop. It checks the value of 'active' before every iteration.
2
active = 0;
Changes the value to zero, which will make the next condition check false.