This is the syntax of a C programming technique used to repeat a block of code while some condition is met.
while (<condition to enter the loop>) { // Loop body }
Graphically, we can represented this as follows:
Important Notes:
- the condition to enter the loop is evaluated first – if not met, the loop body is never executed (contrast to do-while loops)
- that the condition to enter the loop body is reevaluated each time around the loop.
break and continue
As with the for-loop, it is possible to jump to the end of a loop block with the continue statement and break out of the loop early with the break statement.