C++ MCQ Questions with Answers – Part 1
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 of the following operators is called “Address operator”?
A $
B *
C %
D &
2. Which of the following is a correct identifier in C++?
A $my_var
B 2my_var
C MYVAR_9658
D 2MYVAR
3. What is the output of the following C++ program?
#include <iostream> using namespace std; int main ( ) { static double i; i = 15; cout << sizeof(i); return 0; }
A 2
B 4
C 8
D 15
4. What is the correct syntax for including a user-defined header file in C++?
A #include <myfile.h>
B #include <myfile>
C #include "myfile"
D #include [myfile]
5. Who created C++?
A Rasmus Lerdorf
B Bjarne Stroustrup
C James Gosling
D Ken Thompson
7. What is the output of the following C++ program?
#include <iostream> using namespace std; int main() { int n1 = 10; float n2 = 10; cout << sizeof(n1 + n2); return 0; }
A 2
B 4
C 6
D 8
8. Which of the following escape sequences represents a tab?
A \a
B \r
C \t \r
D \t
9. Which of the following escape sequence represents the carriage return?
A \r
B \n
C \n \r
D \t
10. Which of the following used to write a comment in C++?
A // comment
B Both are comments // comment 1 or /* comment 2 */
C /* comment */
D // comment */