ProgrammingHardProduct-company MCQ pattern

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

Assume a 64-bit LP64 ABI. What is printed?
struct Employee {
    char name[20];
    int id;
    float salary;
};
struct Employee e1 = {"Alice", 101, 50000.0f};
struct Employee e2 = e1;
e2.id = 102;
printf("%d %d", e1.id, e2.id);
  1. A. 102 102
  2. B. 101 102
  3. C. 101 101
  4. D. Compile-time error: structs cannot be copy-assigned directly

Correct answer: B. 101 102

struct Employee e2 = e1; performs a full MEMBER-WISE copy of the entire struct (C supports whole-struct assignment/initialization natively), creating an entirely independent object. Changing e2.id afterward has no effect on e1's own copy of id, which stays 101.

More C Programming questions

Exams that ask this topic