read this code: C Programming MCQ Tests | PCBooks - Master C Language Online

C - Programming MCQ Questions and Answers

Test your knowledge of Microsoft Word with these interactive multiple-choice questions.

« First 7 8 9 10 Last »
« Previous Page Next Page »

181. What is the output of: printf("%d", (int(*)[2]){{1,2}}[0][1]);

  • a) 1
  • b) 2
  • c) Compilation error
  • d) Undefined behavior
Answer: B - This nested compound literal creates a pointer to array[2] and accesses element [0][1].

182. Which of these is NOT a valid C11 atomic_flag function?

  • a) atomic_flag_clear_explicit()
  • b) atomic_flag_test_and_set_explicit()
  • c) atomic_flag_load_explicit()
  • d) (No incorrect options - all are valid)
Answer: C - atomic_flag has no load operation (even with explicit memory order).

183. What is the purpose of the 'mtx_trylock()' function?

  • a) Attempt to lock mutex without blocking
  • b) Lock mutex recursively
  • c) Initialize trylock mutex
  • d) Destroy mutex
Answer: A - mtx_trylock() attempts to lock mutex without waiting.

184. What is the output of: printf("%d", 1 | 2 ^ 3 & 4);

  • a) 1
  • b) 3
  • c) 5
  • d) 7
Answer: B - & > ^ > |: 3&4=0, 2^0=2, 1|2=3.

185. Which function is used to copy wide character memory blocks?

  • a) wmemcpy()
  • b) wcpy()
  • c) wmcopy()
  • d) wstrcpy()
Answer: A - wmemcpy() copies wide character memory blocks.

186. What is the value of: (int(*)[2]){{1,2}} + 1

  • a) 1
  • b) 2
  • c) Pointer to next array
  • d) Compilation error
Answer: C - Pointer arithmetic advances by sizeof(int[2]) bytes.

187. Which of these is NOT a valid C11 thread return value?

  • a) thrd_success
  • b) thrd_error
  • c) thrd_failed
  • d) thrd_nomem
Answer: C - thrd_failed doesn't exist (correct are success/error/nomem).

188. What is the output of: printf("%d", 1 * 2 + 3 - 4 / 5);

  • a) 1
  • b) 3
  • c) 5
  • d) 7
Answer: C - / first: 4/5=0, then 1*2=2, 2+3=5, 5-0=5.

189. What is the purpose of the 'mtx_timed' constant?

  • a) Timed mutex
  • b) Non-recursive mutex
  • c) Recursive mutex
  • d) Shared mutex
Answer: A - mtx_timed creates mutex that supports timed operations.

190. What is the output of: printf("%d", 1 << 31 >> 30); (32-bit int)

  • a) -2
  • b) 0
  • c) 2
  • d) Implementation defined
Answer: A - 1<<31 is INT_MIN, >>30 sign-extends to -2.

191. Which function is used to set wide character memory blocks?

  • a) wmemset()
  • b) wset()
  • c) wmset()
  • d) wstrset()
Answer: A - wmemset() sets wide characters in memory block.

192. What is the value of: (int(*)[2]){{1,2}}[0][0] = 3

  • a) 1
  • b) 2
  • c) 3
  • d) Compilation error
Answer: C - Array elements from compound literals are modifiable.

193. Which of these is NOT a valid C11 mutex operation?

  • a) mtx_lock()
  • b) mtx_unlock()
  • c) mtx_trylock()
  • d) mtx_wait()
Answer: D - mtx_wait() doesn't exist (correct are lock/unlock/trylock/timedlock).

194. What is the output of: printf("%d", 1 ? 2 * 3 : 4 / 5);

  • a) 2
  • b) 6
  • c) 0
  • d) Compilation error
Answer: B - 1 is true → evaluates 2*3=6 (ternary has lower precedence than * and /).

195. What is the purpose of the 'cnd_broadcast()' function?

  • a) Wake all threads waiting on condition
  • b) Wake one thread waiting on condition
  • c) Initialize broadcast condition
  • d) Destroy condition variable
Answer: A - cnd_broadcast() wakes all threads waiting on the condition variable.

196. What is the output of: printf("%d", 1 << 4 << 2);

  • a) 16
  • b) 32
  • c) 64
  • d) 256
Answer: C - Left-associative: (1<<4)=16, then 16<<2=64.

197. Which function is used to move wide character memory blocks?

  • a) wmemmove()
  • b) wmove()
  • c) wmmove()
  • d) wstrmove()
Answer: A - wmemmove() safely moves wide character memory (handles overlap).

198. What is the value of: (int(*)[2]){{1,2}}[0][1] = 3

  • a) 1
  • b) 2
  • c) 3
  • d) Compilation error
Answer: C - Array elements from compound literals are modifiable.

199. Which of these is NOT a valid C11 condition variable operation?

  • a) cnd_wait()
  • b) cnd_signal()
  • c) cnd_notify()
  • d) cnd_broadcast()
Answer: C - cnd_notify() doesn't exist (correct are wait/signal/broadcast).

200. What is the output of: printf("%d", 0 ? 2 * 3 : 4 / 5);

  • a) 0
  • b) 6
  • c) 1
  • d) Compilation error
Answer: A - 0 is false → evaluates 4/5=0 (integer division).
« First 7 8 9 10 Last »
« Previous Page Next Page »

Learn Computer Skills with PCBooks

Master computer skills with PCBooks! Explore interactive tutorials, MCQ tests, and online exams for programming, web development, and IT fundamentals. Perfect for beginners and advanced learners.

Online MCQ Tests for Programming

Practice programming MCQ questions and improve your coding skills with our online quizzes. Whether you're learning Python, Java, or C programming, PCBooks has you covered.

Free Web Development Tutorials

Learn HTML, CSS, and JavaScript with our free web development tutorials. Test your knowledge with interactive quizzes and online exams.