ProgrammingHardHCL · Tech Mahindra pattern

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

Assume a 64-bit LP64 ABI. What is printed?
struct Node { char tag; struct Node *next; int val; };
printf("%zu", sizeof(struct Node));
  1. A. 24
  2. B. 16
  3. C. 20
  4. D. 13

Correct answer: A. 24

tag@0 (1 byte), 7 bytes of padding so next can sit at the pointer-aligned offset 8, next@8 (8 bytes), val@16 (4 bytes), then 4 bytes of trailing padding to round the struct to a multiple of 8 (the pointer's alignment): 24 total.

More C Programming questions

Exams that ask this topic