141. What is the output of: printf("%d", (union {int x; float y;}){1}.x);
- a) 0
- b) 1
- c) Compilation error
- d) Undefined behavior
Answer: B - This compound literal creates a union with x=1 and accesses it.
142. Which of these is NOT a valid C11 atomic fetch operation?
- a) atomic_fetch_add()
- b) atomic_fetch_sub()
- c) atomic_fetch_div()
- d) atomic_fetch_xor()
Answer: C - atomic_fetch_div() doesn't exist (correct are add/sub/and/or/xor).
143. What is the purpose of the 'cnd_destroy()' function?
- a) Destroy condition variable
- b) End thread
- c) Free memory
- d) Signal condition
Answer: A - cnd_destroy() releases resources of a condition variable.
144. What is the output of: printf("%d", 1 & 2 | 3);
Answer: D - & has higher precedence: 1&2=0, then 0|3=3.
145. Which function is used to query floating-point categories in C99?
- a) fpclassify()
- b) fptype()
- c) floatcat()
- d) fpcategory()
Answer: A - fpclassify() macro from math.h categorizes floating-point values.
146. What is the value of: (union {int x; float y;}){1} = (union {int x; float y;}){2}
- a) 1
- b) 2
- c) Lvalue required error
- d) Compilation error
Answer: C - Compound literals are not modifiable lvalues.
147. Which of these is NOT a valid C11 thread priority function?
- a) thrd_set_priority()
- b) thrd_get_priority()
- c) thrd_equal()
- d) thrd_current()
Answer: A - C11 doesn't specify thread priority functions.
148. What is the output of: printf("%d", 1 * 2 + 3 % 4);
Answer: C - * and % same precedence: 1*2=2, 3%4=3, then 2+3=5.
149. What is the purpose of the 'tss_delete()' function?
- a) Delete thread-specific storage key
- b) Delete thread
- c) Free memory
- d) Destroy mutex
Answer: A - tss_delete() releases a thread-specific storage key.
150. What is the output of: printf("%d", 1 << 31 >> 31); (32-bit int)
- a) -1
- b) 0
- c) 1
- d) Implementation defined
Answer: D - Right-shifting negative numbers is implementation-defined.
151. Which function is used to search wide character strings?
- a) wcschr()
- b) wschr()
- c) wchr()
- d) wstrchr()
Answer: A - wcschr() finds first occurrence of wide character in string.
152. What is the value of: (union {int x; float y;}*)0 + 1
- a) 0
- b) 1
- c) sizeof(union) bytes
- d) Compilation error
Answer: C - Pointer arithmetic advances by sizeof(union) bytes.
153. Which of these is NOT a valid C11 thread ID function?
- a) thrd_equal()
- b) thrd_current()
- c) thrd_self()
- d) thrd_ident()
Answer: D - thrd_ident() doesn't exist (correct are equal/current).
154. What is the output of: printf("%d", 1 + 2 ? 3 : 4);
- a) 1
- b) 3
- c) 4
- d) Compilation error
Answer: B - + has higher precedence than ?: (1+2)=3 → 3?3:4 → 3.
155. What is the purpose of the 'tss_get()' function?
- a) Get thread-specific value
- b) Get thread priority
- c) Get mutex attribute
- d) Get condition variable
Answer: A - tss_get() retrieves value associated with thread-specific key.
156. What is the output of: printf("%d", 1 << 2 << 2);
Answer: C - Left-associative: (1<<2)=4, then 4<<2=16.
157. Which function is used to tokenize wide character strings?
- a) wcstok()
- b) wstok()
- c) wtok()
- d) wstrtok()
Answer: A - wcstok() tokenizes wide character strings.
158. What is the value of: (union {int x; float y;}){1}.x = 2
- a) 1
- b) 2
- c) Lvalue required error
- d) Compilation error
Answer: B - Union members from compound literals are modifiable (value becomes 2).
159. Which of these is NOT a valid C11 thread state function?
- a) thrd_sleep_for()
- b) thrd_sleep_until()
- c) thrd_wait()
- d) thrd_yield()
Answer: C - thrd_wait() doesn't exist (correct are sleep_for/sleep_until/yield).
160. What is the output of: printf("%d", 1 ? 0 : 1 ? 2 : 3);
Answer: A - Right-associative: 1?0:(1?2:3) → 1 is true → 0.