ProgrammingModerate

struct Acc { int bal; }; void add(struct Acc *a, int x) { a->bal += x; } struct Acc acc = {20}; add(&acc, 7); printf("%d", acc.bal); What is printed?

  1. A. 20
  2. B. 7
  3. C. 34
  4. D. 27

Correct answer: D. 27

Passing the address lets add modify the original struct, so the balance becomes 27.

More C Programming questions

Exams that ask this topic