examples/book/digital-artists/chapter1/Listing1.16.ck
raw| 1 | // Listing 1.16 The for loop |
| 2 | |
| 3 | // For loop |
| 4 | // (1) (2) (3) |
| 5 | for (0 => int i; i < 4; i++) // Begin for structure |
| 6 | { // (4) Block of code to do each time, as |
| 7 | // long as conditional test is true |
| 8 | <<< i >>>; // print value of i; |
| 9 | second => now; // advance time |
| 10 | } |
| 11 | |
| 12 | // (1) Initial setup, usually declare and |
| 13 | // initialize a counter variable |
| 14 | // (2) Conditional test, end condition |
| 15 | // (3) Update thing(s) to do each |
| 16 | // time around the loop, usually |
| 17 | // increment your counter |