ProgrammingModerateTCS NQT · Infosys

What is printed? Assume int is 4 bytes.

What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
    int m[4][5];
    printf("%zu %zu", sizeof m / sizeof m[0], sizeof m[0] / sizeof m[0][0]);
}
  1. A. 20 5
  2. B. 5 4
  3. C. 4 20
  4. D. 4 5

Correct answer: D. 4 5

sizeof m / sizeof m[0] counts the rows, which is 4, and sizeof m[0] / sizeof m[0][0] counts the columns, which is 5.

More C Programming questions

Exams that ask this topic