81. What is the output of: printf("%d", (int[]){1,2}[1]);
- a) 1
- b) 2
- c) Compilation error
- d) Undefined behavior
Answer: B - This compound literal creates an array and accesses index 1 (value 2).
82. Which of these is NOT a valid C11 memory order for atomics?
- a) memory_order_relaxed
- b) memory_order_acquire
- c) memory_order_sync
- d) memory_order_seq_cst
Answer: C - memory_order_sync doesn't exist (correct is memory_order_acq_rel).
83. What is the purpose of the 'static' keyword in function parameters?
- a) Make parameter constant
- b) Preserve parameter value between calls
- c) Restrict parameter scope
- d) Array size indication
Answer: D - In C99+, static in array parameters (like arr[static 10]) indicates minimum size.
84. What is the output of: printf("%d", 1 << -1);
- a) 0
- b) 1
- c) Undefined behavior
- d) Compiler dependent
Answer: C - Negative shift counts are undefined behavior in C.
85. Which function is used to query type alignment in C11?
- a) align()
- b) alignof()
- c) _Alignof()
- d) get_align()
Answer: C - _Alignof (or alignof via stdalign.h) returns alignment requirements.
86. What is the value of: (int){1} + (int){2}
- a) 1
- b) 2
- c) 3
- d) Compilation error
Answer: D - Compound literals can't be operands like this (invalid syntax).
87. Which of these is NOT a valid C11 thread creation function?
- a) thrd_create()
- b) thrd_new()
- c) thrd_detach()
- d) thrd_join()
Answer: B - thrd_new() doesn't exist (correct is thrd_create()).
88. What is the output of: printf("%d", 1 ? 2 : 3, 4);
- a) 1
- b) 2
- c) 4
- d) Compilation warning
Answer: B - The ternary evaluates to 2 (since 1 is true), and 4 is an extra unused argument.
89. What is the purpose of the 'atomic_thread_fence()' function?
- a) Memory fence for atomics
- b) Thread synchronization
- c) Memory allocation
- d) Thread local storage
Answer: A - atomic_thread_fence() (C11) establishes memory ordering constraints.
90. What is the output of: printf("%d", 1 && 0 || 1);
- a) 0
- b) 1
- c) 2
- d) Undefined behavior
Answer: B - && has higher precedence: 1&&0=0, then 0||1=1.
91. Which function is used to query NaN values in C99?
- a) isnan()
- b) isNaN()
- c) fpclassify()
- d) nan()
Answer: A - isnan() macro from math.h tests for NaN values.
92. What is the value of: (int){1,2}[0]
- a) 1
- b) 2
- c) Compilation error
- d) Undefined behavior
Answer: C - Cannot initialize scalar with multiple values in compound literal.
93. Which of these is NOT a valid C11 timespec member?
- a) tv_sec
- b) tv_nsec
- c) tv_usec
- d) tv_msec
Answer: C - timespec has tv_sec and tv_nsec (nanoseconds), not tv_usec.
94. What is the output of: printf("%d", 1 + 2 * 3 / 4);
Answer: B - * and / have same precedence: 2*3=6, 6/4=1 (integer division), 1+1=2.
95. What is the purpose of the 'cnd_t' type in C11?
- a) Condition variables
- b) Thread creation
- c) Memory allocation
- d) Atomic operations
Answer: A - cnd_t is the condition variable type for thread synchronization.
96. What is the output of: printf("%d", 1 << 31); (32-bit int)
- a) -2147483648
- b) 2147483648
- c) Undefined behavior
- d) Implementation defined
Answer: A - Shifting 1 into sign bit gives INT_MIN (-2147483648) in two's complement.
97. Which function is used to compare wide character strings?
- a) wcscmp()
- b) wscmp()
- c) wcmp()
- d) wstrcmp()
Answer: A - wcscmp() compares wide character strings (wchar_t strings).
98. What is the value of: (int[]){1,2,3} + 1
- a) 1
- b) 2
- c) Pointer arithmetic result
- d) Compilation error
Answer: C - Array decays to pointer, +1 gives pointer to second element (can't print directly).
99. Which of these is NOT a valid C11 mutex function?
- a) mtx_init()
- b) mtx_lock()
- c) mtx_wait()
- d) mtx_unlock()
Answer: C - mtx_wait() doesn't exist (condition variables use cnd_wait()).
100. What is the output of: printf("%d", 0 ? 1 : 2 ? 3 : 4);
Answer: C - Right-associative: 0?1:(2?3:4) → 2 is true → 3.