What is the difference between while and do while loop in C?
| while | do while |
|---|---|
| Condition is checked first | Body runs first, condition is checked after |
| Body may run zero times | Body runs at least one time |
| No semicolon after the condition | Semicolon after while (condition); |
Example: with int x = 10; and the condition x < 5, a while loop prints nothing, but a do while loop prints once. See do while loop.
Learn more about the similar topics:
| Tutorials |
|---|
| C If Else Statement |
| C Else If Ladder and Nested If |
| C Switch Statement |
| C While Loop |
| C Do While Loop |
| C For Loop |
| C Nested Loops |