ProgrammingHardGATE CS · TCS NQT

Assume int is 4 bytes. What is printed?

Assume int is 4 bytes. What is printed?
#include <stdio.h>
int main(void) {
    int a[4][5];
    printf("%ld", (long)((char *)&a[3][0] - (char *)&a[0][0]));
}
  1. A. 15
  2. B. 48
  3. C. 60
  4. D. 12

Correct answer: C. 60

Rows are five ints, so a[3][0] is 3 * 5 * 4 = 60 bytes after a[0][0]. Measuring in elements gives 15 instead.

More C Programming questions

Exams that ask this topic