ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
enum E { A = -2, B, C, D = A + 10, E2 };
printf("%d %d %d", B, C, E2);
  1. A. 1 2 9
  2. B. -1 0 9
  3. C. -1 1 9
  4. D. -1 0 11

Correct answer: B. -1 0 9

An enumerator without a value is one more than the previous one: B = −1, C = 0. D = −2 + 10 = 8, so E2 = 9. Enumerators may be negative and may be defined from earlier ones.

More C Programming questions

Exams that ask this topic