ProgrammingHardTCS NQT · Infosys

What is printed? Assume int is 4 bytes.

What is printed? Assume int is 4 bytes.
#include <stdio.h>
int main(void) {
    printf("%d", (int)sizeof(char[3][4]));
}
  1. A. 3
  2. B. 4
  3. C. 12
  4. D. 24

Correct answer: C. 12

char[3][4] has 3 * 4 = 12 one-byte elements, so sizeof gives 12 regardless of int size.

More C Programming questions

Exams that ask this topic