ProgrammingHardProduct company OA

What is printed?

What is printed?
struct In { int a[2]; };
struct Out { struct In in[2]; int k; } o = {{{{1, 2}}, {{3, 4}}}, 5};
printf("%d %d", o.in[1].a[0], o.in[0].a[1] + o.k);
  1. A. 3 6
  2. B. 2 7
  3. C. 1 7
  4. D. 3 7

Correct answer: D. 3 7

The braces follow the nesting: the outer struct, then the array in, then each struct In, then each array a. So in[0].a = {1, 2}, in[1].a = {3, 4} and k = 5. in[1].a[0] = 3 and 2 + 5 = 7.

More C Programming questions

Exams that ask this topic