|
| mikroC | |
mikroC - C Compiler for Microchip PIC microcontrollers | making it simple... | ||
|
|
|
|
Do Statement
The do statement executes until the condition becomes false. Syntax of do statement is:
do statement while (expression);
The statement is executed repeatedly as long as the value of expression remains
Parentheses around expression are mandatory.
Note that do is the only control structure in C which explicitly ends with semicolon (;). Other control structures end with statement which means that they implicitly include a semicolon or a closing brace.
Here is an example of calculating scalar product of two vectors, using the do statement:
s = 0; i = 0; do {
s += a[i] * b[i]; i++;
} while (i < n);
page
120
For Statement
The for statement implements an iterative loop. Syntax of for statement is:
for
Before the first iteration of the loop, expression
Expression
MikroElektronika: Development tools - Books - Compilers