Skip to the task
Layout
Back to classic view

You are looking at lesson 6. Your place is still lesson 11, task 1: fopen.

CHECKTask 23 of 28 · step 9: Drills: check yourself

Column by column

What do these nested loops print?

int m[2][3] = {{1, 2, 3}, {4, 5, 6}};
for (int c = 0; c < 3; c++) {
    for (int r = 0; r < 2; r++) {
        printf("%d ", m[r][c]);
    }
}
Stuck?

1 4 2 5 3 6: the outer loop goes over the columns, so the array is printed column by column.