ProgrammingHard
enum { A = 3, B, C = 10, D }; printf("%d", B + D); What is printed?
- A. 12
- B. 15
- C. 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
- printf("%d", 1 ? 'a' : 0); What is printed?
- #define SQ(x) ((x) (x)) printf("%d", SQ(2 + 1)); What is printed?
- #define ADD(a, b) a + b printf("%d", ADD(1, 2) 3); What is printed?
- char grid[2] = {"ab", "cd"}; printf("%c", grid[1][0]); What is printed?
- struct S { int a; char c; } arr[2] = {{1}}; printf("%d", arr[1].a); What is printed?
- int a[5] = {[2] = 7, 9}; printf("%d", a[3]); What is printed?