ProgrammingHard

struct Acc { int bal; }; void add(struct Acc a, int x) { a.bal += x; } struct Acc acc = {10}; add(acc, 5); printf("%d", acc.bal); What is printed?

  1. A. 15
  2. B. 5
  3. C. 10
  4. D. 0

Correct answer: C. 10

Structs are passed by value, so add changes only its own copy. acc keeps 10.

More C Programming questions

Exams that ask this topic