mikroElektronika PIC Microcontrollers PIC12 User Manual page 129

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...
All the expressions are optional. If
always true. Thus, "empty" for statement is commonly used to create an endless
loop in C:
for ( ; ; ) {...}
The only way to break out of this loop is by means of
Here is an example of calculating scalar product of two vectors, using the
statement:
for (s = 0, i = 0; i < n; i++) s += a[i] * b[i];
You can also do it like this:
/* valid, but ugly */
for (s = 0, i = 0; i < n; s += a[i] * b[i], i++);
but this is considered a bad programming style. Although legal, calculating the
sum should not be a part of the incrementing expression, because it is not in the
service of loop routine. Note that we used a null statement (
MikroElektronika: Development tools - Books - Compilers
mikroC - C Compiler for Microchip PIC microcontrollers
is left out, it is assumed to be
condition-exp
statement.
break
for
) for a loop body.
;
page
121

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents