ProgrammingHard

struct Item { int id; int qty; }; struct Item a[2] = {{1, 5}, {2, 7}}; struct Item b = a[1]; b.qty = 0; printf("%d %d", a[1].qty, b.qty); What is printed?

  1. A. 7 0
  2. B. 0 0
  3. C. 7 7
  4. D. 0 7

Correct answer: A. 7 0

Assigning a struct copies it, so changing b does not change a[1]. a keeps 7 and b has 0.

More C Programming questions

Exams that ask this topic