ProgrammingHard

struct Cfg { int depth; int width; }; struct Cfg cfg[2] = {{1, 2}, {3, 4}}; struct Cfg *cp = &cfg[1]; cp->width *= 10; printf("%d", cfg[1].width); What is printed?

  1. A. 4
  2. B. 30
  3. C. 40
  4. D. 34

Correct answer: C. 40

cp points at cfg[1], so the multiplication changes that element. Its width becomes 4 x 10 = 40.

More C Programming questions

Exams that ask this topic