Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of the `return` statement in a function?
1) To exit the function
2) To return a value from the function
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What will be the output of printf("%d", 5 + 5 * 2);?
1) 15
2) 10
3) 5
4) 20
Answer : 15
Which of the following is not a loop control statement in C?
1) for
2) while
3) do while
4) goto
Answer : goto
What is the output of printf("%d", 10 - 2 * 3 + 1);?
1) 5
2) 6
3) 7
4) 4
Answer : 5
Which of the following is the correct syntax to declare a character pointer?
1) char *ptr;
2) char ptr*;
3) *char ptr;
4) None of the above
Answer : char *ptr;
Which of the following is a valid statement to declare a function pointer?
1) int (*f)();
2) int f();
3) void f*();
4) void (*f)();
Answer : int (*f)();
What is the output of printf("%d", 15 & 7);?
1) 15
2) 7
3) 1
4) 0
Answer : 7
Which of the following functions returns a pointer to a character in C?
1) strchr()
2) strdup()
3) strcpy()
4) strlen()
Answer : strchr()
What will be the output of printf("%d", (3 + 5) * 2);?
1) 16
2) 20
3) 8
4) 14
Answer : 16
Which of the following is true about the `while` loop in C?
1) It executes at least once.
2) It checks the condition at the beginning.
3) It does not require a condition.
4) None of the above
Answer : It checks the condition at the beginning.