Learn C MCQs

Prepare C MCQs (Multiple choice Questions) for exam and job interviews.

Which function is used to write formatted output to a string in C?

1) strwrite()

2) sprintf()

3) strprintf()

4) fwrite()

Answer : Option 2

What is the correct way to handle multiple errors in C?

1) Using a switch case

2) Using multiple if conditions

3) Using error handlers

4) Using error codes

Answer : Option 4

Which of the following is not a valid loop structure in C?

1) for

2) while

3) foreach

4) do-while

Answer : Option 3

What is the output of printf("%d", 9 % 2);?

1) 1

2) 2

3) 4

4) 0

Answer : Option 1

Which of the following operators is used for bitwise AND?

1) &

2) |

3) ^

4) ~

Answer : Option 1

Which header file is required for dynamic memory allocation functions?

1) stdio.h

2) stdlib.h

3) conio.h

4) math.h

Answer : Option 2

Which operator is used to check equality in C?

1) =

2) ==

3) ===

4) !=

Answer : Option 2

What is the output of printf("%d", 5 == 5);?

1) 0

2) 1

3) Error

4) 5

Answer : Option 2

Which of the following is not a logical operator in C?

1) &&

2) ||

3) !

4) &

Answer : Option 4

Which keyword is used to exit a loop prematurely?

1) exit

2) break

3) return

4) continue

Answer : Option 2