Learn C MCQs
Prepare C MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of printf("%d", 5 + 10 * 2);?
1) 25
2) 20
3) 15
4) 30
Answer : 25
Which of the following statements is true about the `do while` loop?
1) It executes at least once.
2) It checks the condition at the beginning.
3) It requires a break statement.
4) None of the above
Answer : It executes at least once.
What is the purpose of the `enum` keyword in C?
1) To define constants
2) To define a variable
3) To define a function
4) To define a type
Answer : To define a type
What will be the output of printf("%d", 1 << 2);?
1) 2
2) 4
3) 8
4) 16
Answer : 4
Which of the following is used to include a header file in C?
1) #include <filename>
2) #include filename
3) import filename
4) require filename
Answer : #include <filename>
What is the output of printf("%d", (5 + 3) * 2);?
1) 16
2) 12
3) 8
4) 10
Answer : 16
Which of the following is the correct syntax for a function that takes two integers and returns their sum?
1) int sum(int a, int b) {}
2) sum(int a, int b) {return a + b;}
3) void sum(int a, int b) {return a + b;}
4) int sum(a, b) {return a + b;}
Answer : int sum(int a, int b) {}
What is the output of printf("%d", 10 / 2 + 3);?
1) 5
2) 6
3) 7
4) 8
Answer : 8
Which of the following is not a valid variable name in C?
1) myVar
2) my-var
3) _myVar
4) 1stVar
Answer : my-var
What is the output of printf("%d", 8 & 5);?
1) 1
2) 0
3) 3
4) 5
Answer : Option 3