ProgrammingModerate
int m[2][5]; printf("%zu", sizeof m[0]); What is printed on a platform with 4-byte int?
- A. 5
- B. 20
- C. 10
- D. 40
Correct answer: B. 20
m[0] is one row of five ints, so 5 x 4 = 20 bytes. sizeof m would be 40.
More C Programming questions
- int r = 2, c = 5; int m[r][c]; printf("%zu", sizeof m); What is printed on a platform with 4-byte int (C99 variable-length array)?
- int m[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; int (row)[4] = m; printf("%d", ((row + 2))[3]); What is printed?
- char g[2][3] = {"ab", "cde"}; printf("%c", g[1][2]); What is printed?
- int grid[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; int s = 0; for (int i = 0; i < 3; i++) s += grid[i][2 - i]; printf("%d", s); What is…
- int a[4][4] = {0}; for (int i = 0; i < 4; i++) a[i][i] = a[i][3 - i] = 1; int c = 0; for (int i = 0; i < 4; i++) for (int j = 0; j < 4…
- A 5 x 5 grid is stored as an int matrix. Which expression gives the number of cells on its main diagonal?