Bifalgorithm post · Computer science one · Do-While Loops
How does a do-while loop differ from a while loop in C?
How does a do-while loop differ from a while loop in C? (Computer science one · Do-While Loops) — "C supports do-while loops. Recall that the difference betwee…
Ideas in this flowchart
- C supports do-while loops.
- The key difference between while and do-while loops is when the continuation condition is checked.
- In a while loop, the condition is checked before the loop body begins.
- In a do-while loop, the condition is checked at the end of the loop.
- A do-while loop therefore always executes at least once.
- An example appears in Code Sample 17.4.
- The do-while syntax has specific formatting conventions.
- The opening curly bracket is on the same line as the do keyword.
- The while keyword and continuation condition are on the same line as the closing curly bracket.