do while in C in C Language
Updated on May 31, 2025 | By Learnzy Academy
The do while loop in Cis a control flow statement that allows a block of code to be executed at least once, and then repeatedly based on a given condition.
Unlike the while loop, which checks the condition before the first execution, the do while loop checks the condition after the code block runs. This guarantees that the loop body runs at least one time, even if the condition is false initially.
Syntax:
do {
// code to execute
} while (condition);
Key points of do while loop:-
- The loop body runs at least once, even if the condition is false.
- The condition is checked after the loop body is executed.
- The loop will keep running as long as the condition evaluates to true.
- It ends with a semicolon after the while(condition) — don’t forget it!
Click here to download practice questions on
do while in C