boot2

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

010-array-2d.c (469B)


      1 /* tests/cc-e2e/10-array-2d.c — local 2-D array initializer + nested loop sum.
      2  * Split from 01-kitchen-sink. */
      3 
      4 int test_array_2d(void) {
      5     int m[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
      6     int sum = 0;
      7     int i; int j;
      8     for (i = 0; i < 2; i = i + 1)
      9         for (j = 0; j < 3; j = j + 1)
     10             sum = sum + m[i][j];
     11     return sum;                     /* 21 */
     12 }
     13 
     14 int main(int argc, char **argv) {
     15     if (test_array_2d() != 21) return 1;
     16     return 0;
     17 }