while loops
These loops are control-flow statements that let code execute repeatedly based on a given Boolean (true/false) condition. A while loop can be thought of as a repeating "if" statement and consists of a block of code and a condition. Upon evaluation, if the condition is true, the code in the block is executed, repeating until the condition becomes false. A >while loop checks the condition before the block is executed, in contrast to a do…while loop, which tests the condition after the block is executed.
Syntax (while loops) | Example |
---|---|
|
|