ProgrammingVery hardTCS NQT · Infosys pattern

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

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

Correct answer: B. 16

val@0 (4 bytes). next is a pointer (align 8), so it cannot start at offset 4; it's pushed to offset 8 (4 padding bytes) and occupies 8-15. End is already 16, a multiple of 8.

More C Programming questions

Exams that ask this topic