Understanding do...while loop in C
What is a do...while Loop?
The do...while loop is an exit-controlled loop — its body executes at least once before the condition is checked.
Syntax
do {
// statements
} while (condition);
Example
int i = 1;
do {
printf("%d ", i);
i++;
} while (i <= 5);
// Output: 1 2 3 4 5
do...while vs while
Unlike a while loop, a do...while loop always runs its body at least once, even if the condition is false from the start.
Ready to master real-world C Programming development?
Learn C Programming hands-on with mentor-led, live sessions.
.png)