ProgrammingModerate

struct In { int v; }; struct Out { struct In in; int k; }; struct Out o = {{7}, 2}; printf("%d", o.in.v + o.k); What is printed?

  1. A. 7
  2. B. 9
  3. C. 2
  4. D. 5

Correct answer: B. 9

The inner braces {7} initialise the nested struct, so o.in.v = 7 and o.k = 2, and the sum is 9. 7 or 2 alone pick just one field, and 5 subtracts them.

More C Programming questions

Exams that ask this topic