boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

022-loops.c (514B)


      1 /* tests/cc-e2e/22-loops.c — do-while + while + continue.
      2  * Split from 01-kitchen-sink. */
      3 
      4 int test_loops(void) {
      5     int x = 0;
      6     do { x = x + 1; } while (x < 3);            /* x = 3 */
      7     int y = 0;
      8     while (y < 10) {
      9         y = y + 1;
     10         if (y == 5) continue;
     11         x = x + 1;
     12     }                                           /* x = 3 + 9 = 12 */
     13     return x;                                   /* 12 */
     14 }
     15 
     16 int main(int argc, char **argv) {
     17     if (test_loops() != 12) return 1;
     18     return 0;
     19 }