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 : sprintf()
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 : Using error codes
Which of the following is not a valid loop structure in C?
1) for
2) while
3) foreach
4) do-while
Answer : foreach
What is the output of printf("%d", 9 % 2);?
1) 1
2) 2
3) 4
4) 0
Answer : 1
Which of the following operators is used for bitwise AND?
1) &
2) |
3) ^
4) ~
Answer : &
Which header file is required for dynamic memory allocation functions?
1) stdio.h
2) stdlib.h
3) conio.h
4) math.h
Answer : stdlib.h
Which operator is used to check equality in C?
1) =
2) ==
3) ===
4) !=
Answer : ==
What is the output of printf("%d", 5 == 5);?
1) 0
2) 1
3) Error
4) 5
Answer : 1
Which of the following is not a logical operator in C?
1) &&
2) ||
3) !
4) &
Answer : &
Which keyword is used to exit a loop prematurely?
1) exit
2) break
3) return
4) continue
Answer : break