Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 400 Bytes

File metadata and controls

38 lines (31 loc) · 400 Bytes

For Loop


Back

for(init; condition; count) {
    doLoop();
}

Example:

int i;

for(i=0; i<5; i++) {
    printf("i=%d\r\n", i);
}

produces:

i=0
i=1
i=2
i=3
i=4

The initialization, the condition and the count each can be empty too. For example to write an endless loop, it can be written as:

int i;

for(;;) {
  /* endless loop */
}