ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
#pragma pack(push, 1)
struct Packed { char c; int i; };
#pragma pack(pop)
printf("%zu", sizeof(struct Packed));
  1. A. 6
  2. B. 8
  3. C. 4
  4. D. 5

Correct answer: D. 5

#pragma pack(1) forces 1-byte alignment for every member, eliminating padding entirely, so the struct's size is simply the sum of its members: 1 + 4 = 5 bytes.

More C Programming questions

Exams that ask this topic