Do-while loop
A do-while loop is a control-flow construct that executes its body before testing a condition, then repeats while the condition is true.
Modern C, Third Edition
A do-while loop is a C iteration statement that executes its body once and then repeats it while its controlling condition is true.
- How it is used
- Deploys post-tested iteration when an operation must execute before deciding whether repetition should continue.
- How deep it goes
- Defines syntax and execution order, demonstrates a numerical loop, and stops short of deeper control-flow mechanics.
- Examples
- Demonstrates Heron's approximation for a multiplicative inverse using a precision threshold and repeated updates.
- What you can do after
- Apply it via C syntax to repeat a body at least once and terminate after a condition becomes false.
Modern C
A do-while loop is a C iteration construct that executes its dependent statement before testing whether its condition remains true.
- How it is used
- Uses post-condition iteration when an operation must occur before deciding whether repetition should continue.
- How deep it goes
- Defines syntax, contrasts do with while, and demonstrates a numerical rewrite without developing implementation internals.
- Examples
- Demonstrates do by rewriting Heron’s approximation for computing multiplicative inverses.
- What you can do after
- Apply via C syntax to place a continuation test after an iteration body.
Also covered in
- 100 C++ Mistakes and How to Avoid Them
- Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
What to know first
- conditional logicConditional logic is a programming technique that evaluates conditions to select among execution paths, actions, or result values.
- scopeScope is the region of a program in which names are visible and can be resolved to their bindings according to the language’s rules.
- size_tsize_t is an unsigned integer type in C and C++ used to represent object sizes and related counts.
- valueA value is a quantity, datum, or measure of significance attributed to or represented by an entity, property, expression, or outcome.
Related concepts
- loopkind of · A loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- infinite loopproduces · An infinite loop is a control-flow cycle that continues without reaching a normal termination point unless an exit condition or external intervention stops it.
- statementkind of · A statement is a syntactic unit in a programming or query language that expresses an instruction, declaration, or control operation for a processor to execute.
- type-generic macroused by · A type-generic macro is a macro-based interface whose expansion selects or adapts operations according to the types of its arguments or associated objects.
- do-while(false) trickimplemented by · The do-while(false) trick is a macro-structuring technique that encloses multiple statements in a single statement-like construct.
Questions about do-while loop
What is do-while loop?
A do-while loop is a control-flow construct that executes its body before testing a condition, then repeats while the condition is true.
Which Manning books explain do-while loop?
Modern C, Third Edition and Modern C.
What should I know before learning do-while loop?
Manning books that teach do-while loop usually introduce conditional logic, scope, size_t and value first.
What is do-while loop a kind of?
Do-while loop is a kind of loop. A loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
What is do-while loop also called?
Do-while loop is also called do loop.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

