English
Language : 

CC78K4 Datasheet, PDF (118/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 6 CONTROL STRUCTURES OF C LANGUAGE
(2) do statement
Iteration Statements
do statement
FUNCTION
A do statement executes the body of the loop as long as the control expression enclosed in parentheses is True
(nonzero). The do statement evaluates the control expression after the loop body has been executed.
SYNTAX
do statements while (expression) ;
EXAMPLE
Int i, x ;
void main (void) {
i=1, x=0 ;
do {
x += i ;
i++ ;
} while( i<11 );
}
EXPLANATION
The above example finds the sum total of integers from 1 to 10 for x. The two statements enclosed in braces are
the body of this do ... while loop. The control expression “i<11” returns 0 if the value of i becomes 11. For this
reason, the loop body is executed repeatedly as long as the value of i is less than 11 (between 1 and 10). The
body of the loop is always performed once or more since the control expression of a do statement is evaluated
after execution.
118
User’s Manual U15556EJ1V0UM