Abl-electronic PIC Microcontrollers PIC16 Manual do Utilizador Página 127

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 312
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 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...
Vista de página 126
1 2 ... 122 123 124 125 126 127 128 129 130 131 132 ... 311 312

Comentários a estes Manuais

Sem comentários