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 5 6 7 8 Last »
« Previous Page Next Page »

101. What is the output of: printf("%d", (int){1.5});

  • a) 1
  • b) 1.5
  • c) Compilation error
  • d) Undefined behavior
Answer: A - The compound literal converts 1.5 to int (truncates to 1).

102. Which of these is NOT a valid C11 atomic flag operation?

  • a) atomic_flag_test_and_set()
  • b) atomic_flag_clear()
  • c) atomic_flag_load()
  • d) atomic_flag_init()
Answer: C - atomic_flag has no load operation (only test_and_set/clear).

103. What is the purpose of the 'thread_local' keyword?

  • a) Thread synchronization
  • b) Thread-specific storage
  • c) Thread creation
  • d) Thread termination
Answer: B - thread_local (C11) declares variables with thread storage duration.

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

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

105. Which function is used to query infinity in C99?

  • a) isinf()
  • b) isInfinite()
  • c) fpclassify()
  • d) inf()
Answer: A - isinf() macro from math.h tests for infinity.

106. What is the value of: (int[]){1}+1

  • a) 1
  • b) 2
  • c) Pointer to second element
  • d) Compilation error
Answer: C - Array decays to pointer, +1 gives pointer to (non-existent) second element.

107. Which of these is NOT a valid C11 thread exit reason?

  • a) thrd_success
  • b) thrd_error
  • c) thrd_failed
  • d) thrd_busy
Answer: D - thrd_busy is not a standard exit code (others are).

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

  • a) 1
  • b) 2
  • c) 3
  • d) 4
Answer: C - * and % same precedence: 2*3=6, 6%4=2, then 1+2=3.

109. What is the purpose of the 'mtx_t' type in C11?

  • a) Mutex synchronization
  • b) Memory allocation
  • c) Thread creation
  • d) Atomic operations
Answer: A - mtx_t is the mutex type for thread synchronization.

110. What is the output of: printf("%d", 1 << 63); (64-bit long)

  • a) -9223372036854775808
  • b) 9223372036854775808
  • c) Undefined behavior
  • d) Implementation defined
Answer: A - Shifting 1 into sign bit gives LONG_MIN (-2^63) in two's complement.

111. Which function is used to copy wide character strings?

  • a) wcscpy()
  • b) wscpy()
  • c) wcpy()
  • d) wstrcpy()
Answer: A - wcscpy() copies wide character strings (wchar_t strings).

112. What is the value of: (int){1} = 2

  • a) 1
  • b) 2
  • c) Lvalue required error
  • d) Compilation error
Answer: C - Compound literals are not modifiable lvalues.

113. Which of these is NOT a valid C11 condition variable function?

  • a) cnd_wait()
  • b) cnd_signal()
  • c) cnd_notify()
  • d) cnd_broadcast()
Answer: C - cnd_notify() doesn't exist (correct is cnd_signal()).

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

  • a) 2
  • b) 3
  • c) 4
  • d) 5
Answer: A - 1 is true → first branch taken (2), second ternary not evaluated.

115. What is the purpose of the 'tss_t' type in C11?

  • a) Thread-specific storage
  • b) Thread synchronization
  • c) Thread creation
  • d) Thread termination
Answer: A - tss_t manages thread-specific storage keys.

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

  • a) 2
  • b) 4
  • c) 8
  • d) 16
Answer: C - Left-associative: (((1<<1)<<1)<<1) → 1→2→4→8.

117. Which function is used to concatenate wide character strings?

  • a) wcscat()
  • b) wscat()
  • c) wcat()
  • d) wstrcat()
Answer: A - wcscat() concatenates wide character strings.

118. What is the value of: (int[]){1}[0] = 2

  • a) 1
  • b) 2
  • c) Lvalue required error
  • d) Compilation error
Answer: B - Array elements from compound literals are modifiable (value becomes 2).

119. Which of these is NOT a valid C11 thread yield function?

  • a) thrd_yield()
  • b) thrd_sleep()
  • c) thrd_sleep_for()
  • d) thrd_sleep_until()
Answer: B - thrd_sleep() doesn't exist (correct are yield/sleep_for/sleep_until).

120. What is the output of: printf("%d", 0 ? 1 : 1 ? 2 : 3);

  • a) 1
  • b) 2
  • c) 3
  • d) 4
Answer: B - Right-associative: 0?1:(1?2:3) → 1 is true → 2.
« First 5 6 7 8 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.