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

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

  • a) 1
  • b) 3
  • c) 5
  • d) Compilation warning
Answer: B - The ternary operator returns 3 (since 1<2 is true), and the 5 is an extra unused argument.

62. Which of these is NOT a valid C11 atomic type qualifier?

  • a) _Atomic
  • b) atomic_int
  • c) atomic_bool
  • d) atomic_float
Answer: D - atomic_float is not a standard atomic type (C11 has atomic_int, atomic_bool, etc.).

63. What is the purpose of the 'complex' keyword in C?

  • a) Complex control flow
  • b) Complex numbers support
  • c) Complex data structures
  • d) Complex macros
Answer: B - complex (and _Complex) are used for complex number support (requires complex.h).

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

  • a) 1
  • b) 2
  • c) 3
  • d) 4
Answer: C - & has higher precedence than |, so 2&3=2, then 1|2=3.

65. Which function is used to set the FPU rounding direction?

  • a) fesetround()
  • b) fsetround()
  • c) setfround()
  • d) roundset()
Answer: A - fesetround() from fenv.h sets floating-point rounding direction.

66. What is the value of: (struct {int x;}*)0

  • a) NULL pointer
  • b) Pointer to address 0
  • c) Compilation error
  • d) Runtime error
Answer: B - This is a null pointer of type "pointer to struct", not necessarily NULL macro.

67. Which of these is NOT a valid C99 math library function?

  • a) log2()
  • b) exp2()
  • c) pow2()
  • d) hypot()
Answer: C - pow2() doesn't exist (use pow(2,x) or exp2(x) instead).

68. What is the output of: printf("%d", sizeof(1==1));

  • a) 1
  • b) 2
  • c) 4
  • d) Compiler dependent
Answer: C - In C, boolean expressions result in int (typically 4 bytes), not bool type.

69. What is the purpose of the 'noreturn' attribute?

  • a) Prevent function returns
  • b) Optimize tail calls
  • c) Mark non-returning functions
  • d) Disable recursion
Answer: C - _Noreturn (C11) or __attribute__((noreturn)) indicates functions don't return.

70. What is the output of: printf("%d", 0 || !1 && 1);

  • a) 0
  • b) 1
  • c) 2
  • d) Compilation error
Answer: A - && has higher precedence than ||: !1=0, 0&&1=0, then 0||0=0.

71. Which function is used to query FPU exception flags?

  • a) fegetexceptflag()
  • b) fetestexcept()
  • c) fexcepttest()
  • d) fpuexcept()
Answer: B - fetestexcept() from fenv.h tests floating-point exceptions.

72. What is the value of: (int){3.14}

  • a) 3
  • b) 3.14
  • c) Compilation error
  • d) Undefined behavior
Answer: C - Cannot use compound literal with cast (invalid syntax).

73. Which of these is NOT a valid C11 threading feature?

  • a) thrd_create()
  • b) mtx_lock()
  • c) cnd_wait()
  • d) tls_get()
Answer: D - C11 uses thread_local for TLS, not tls_get() function.

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

  • a) 0
  • b) 1
  • c) 2
  • d) 3
Answer: C - * and / have same precedence: 3/4=0 (integer division), then 1*2+0=2.

75. What is the purpose of the 'quick_exit()' function?

  • a) Fast program termination
  • b) Thread termination
  • c) Signal handling
  • d) Process forking
Answer: A - quick_exit() (C11) terminates program without calling full cleanup.

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

  • a) 0
  • b) 1
  • c) Undefined behavior
  • d) Compilation error
Answer: C - Shifting by >= width of type is undefined behavior.

77. Which function is used to copy memory between overlapping regions?

  • a) memcpy()
  • b) memmove()
  • c) mempcpy()
  • d) bcopy()
Answer: B - memmove() safely handles overlapping memory regions.

78. What is the value of: (int){1} + 2

  • a) 1
  • b) 2
  • c) 3
  • d) Compilation error
Answer: D - Compound literals can't be used in expressions this way.

79. Which of these is NOT a valid C11 alignment feature?

  • a) alignas
  • b) alignof
  • c) _Alignas
  • d) memalign
Answer: D - memalign() is a POSIX function, not C11 standard.

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

  • a) 0
  • b) 1
  • c) 2
  • d) Compilation error
Answer: B - The GNU extension ?: (omitted middle operand) returns the condition if true.
« First 3 4 5 6 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.