C++ MCQ Questions and Answers – Part 10
Multiple choice questions and answers (MCQs) on C++ to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as Variables, Operators, Conditional Statement, Functions, and more. This quiz will easily prepare anyone to pass their online test.
1. Which character is used to terminate a structure?
A :
B }
C ;
D ;;
2. A void pointer can point to what type of objects?
A int
B double
C float
D All the answers are true
[st_adsense]
3. The pointer can point to any variable not declared with _____
A const
B volatile
C const and volatile
D static
4. What is the output of the following C++ code?
#include <iostream> using namespace std; int main() { int x; x = 5 + 2 * 5; cout << x; return 0; }
A 35
B 15
C 27
D 15
5. What will happen when a structure is declared?
A It won’t allocate any memory
B It will allocate the memory
C It is declared and initialized
D None of the above
[st_adsense]
6. What is the output of the following C++ code?
#include <iostream> using namespace std; int main() { int x = 2, y = 3, z, w; z = x, y; w = (x, y); cout << z << ' ' << w; return 0; }
A 2 3
B 3 2
C 2 2
D 3 3
7. What is the size of a generic pointer in C++ (on a 32 bits platform)?
A 2
B 4
C 8
D None of the above
8. What is the purpose of ‘p’ in the following statement?
int (*p[3]) ();
A p is a pointer to a function
B p is an array of pointers to a function
C p is a pointer to a function whose return type is an array
D p is a pointer to a function array
[st_adsense]
9. A void pointer cannot point to ______
A class members in C++
B methods in C++
C All the answers are true
D None of the above
10. What is the output of the following C++ code?
#include <iostream> using namespace std; int main() { int *p1; void *p2; if (p1 == p2); cout << "equal"; return 0; }
A equal
B No output
C Runtime error
D Compilation error
[st_adsense]