ProgrammingHard

enum { A = 3, B, C = 10, D }; printf("%d", B + D); What is printed?

  1. A. 12
  2. B. 15
  3. C. 4
  4. D. 14

Correct answer: B. 15

An enumerator without a value is the previous one plus 1: B = 4, and D follows C = 10, so D = 11 and B + D = 15. 14 takes D as 10, 12 uses B's position (1) instead of its value, and 4 uses positions for both (1 + 3).

More C Programming questions

Exams that ask this topic