Abl-electronic PIC Microcontrollers PIC16 Manuel d'utilisateur Page 127

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 312
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 126
Iteration Statements
Iteration statements let you loop a set of statements. There are three forms of itera-
tion statements in C: while, do, and for.
While Statement
Use the
while keyword to conditionally iterate a statement. Syntax of while
statement is:
while (
expression
)
statement
The
statement
executes repeatedly until the value of expression is false. The test
takes place before
statement
executes. Thus, if
expression
evaluates to false
on the first pass, the loop does not execute.
Parentheses around
expression
are mandatory.
Here is an example of calculating scalar product of two vectors, using the
while
statement:
int s = 0, i = 0;
while (i < n) {
s += a[i] * b[i];
i++;
}
Note that body of a loop can be a null statement. For example:
while (*q++ = *p++);
MikroElektronika:
Development
tools
-
Books
-
Compilers
119
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Vue de la page 126
1 2 ... 122 123 124 125 126 127 128 129 130 131 132 ... 311 312

Commentaires sur ces manuels

Pas de commentaire