ProgrammingHardHCL · Tech Mahindra pattern

Assume 64-bit LP64, natural alignment. What is printed?

Assume 64-bit LP64, natural alignment. What is printed?
struct A { int arr[3]; char c; };
printf("%zu", sizeof(struct A));
  1. A. 16
  2. B. 13
  3. C. 12
  4. D. 15

Correct answer: A. 16

arr occupies 12 bytes (3 ints), already aligned; c follows at offset 12 (1 byte), making the raw total 13. The struct must then be padded to a multiple of 4 (int's alignment, the strictest member), rounding up to 16.

More C Programming questions

Exams that ask this topic