ProgrammingHardProduct company OA

Assume a 64-bit LP64 ABI. What is printed?

Assume a 64-bit LP64 ABI. What is printed?
union Val { int i; float f; };
union Val arr[4];
printf("%zu %zu", sizeof(union Val), sizeof(arr));
  1. A. 8 32
  2. B. 4 8
  3. C. 8 16
  4. D. 4 16

Correct answer: D. 4 16

Both members of Val are 4 bytes with 4-byte alignment, so the union itself is 4 bytes. An array of 4 such unions is simply 4 x 4 = 16 bytes.

More C Programming questions

Exams that ask this topic