Question 8
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
int main(void) {
int m[4][5];
printf("%zu %zu %zu\n", sizeof m, sizeof m[0], sizeof m[0][0]);
return 0;
}
- A 80 20 4 Correct
- B 20 5 4
- C 80 8 4
- D 80 20 8
Correct Answer: Option A
The whole matrix is 4 × 5 × 4 = 80 bytes. m[0] is one row of 5 ints = 20 bytes (an array, not a pointer, under sizeof), and one element is 4 bytes.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!