Learn C++ MCQs
Prepare C++ MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of cout << (12 / 4 + 3) << endl;
1) 6
2) 4
3) 5
4) None of the above
Answer : 6
What is the correct way to declare an inline function?
1) inline void func() {}
2) void inline func() {}
3) Both 1 and 2
4) None of the above
Answer : inline void func() {}
Which of the following is a valid use of the break statement?
1) To exit a loop
2) To exit a switch case
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of cout << (5 ^ 3) << endl;
1) 6
2) 2
3) 1
4) None of the above
Answer : 6
Which of the following statements is true about C++?
1) C++ does not support OOP.
2) C++ is a portable language.
3) C++ is slower than C.
4) None of the above
Answer : C++ is a portable language.
Which of the following is the correct way to declare a pointer in C++?
1) int* ptr;
2) int ptr*;
3) int &ptr;
4) None of the above
Answer : int* ptr;
What will be the output of cout << (9 / 2) << endl;
1) 4
2) 5
3) 4.5
4) None of the above
Answer : 4
Which of the following allows a function to have variable number of arguments in C++?
1) variadic functions
2) default arguments
3) overloading
4) None of the above
Answer : variadic functions
What is the output of cout << (false || true) << endl;
1) 1
2) 0
3) true
4) false
Answer : 1
Which of the following is a type of polymorphism in C++?
1) Compile-time polymorphism
2) Run-time polymorphism
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2