ProgrammingVery hard

struct Q { char name[6]; double score; char tag; }; with 8-byte double and natural alignment. What is sizeof(struct Q)?

  1. A. 16
  2. B. 23
  3. C. 32
  4. D. 24

Correct answer: D. 24

name takes offsets 0 to 5, so score starts at offset 8 (pad to 8). tag is at offset 16. The size is 17 bytes, padded to the 8-byte alignment, which gives 24.

More C Programming questions

Exams that ask this topic