Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Arduino - dowhile loop



The dowhile loop is similar to the while loop. In the while loop, the loop-continuation condition is tested at the beginning of the loop before performed the body of the loop. The dowhile statement tests the loop-continuation condition after performed the loop body. Therefore, the loop body will be executed at least once.

When a dowhile terminates, execution continues with the statement after the while clause. It is not necessary to use braces in the dowhile statement if there is only one statement in the body. However, the braces are usually included to avoid confusion between the while and dowhile statements.

dowhile loop Syntax

do { 
   Block of statements; 
} 
while (expression);
arduino_loops.htm
Advertisements