Learn C++ MCQs

Prepare C++ MCQs (Multiple choice Questions) for exam and job interviews.

Which of the following is used to allocate memory dynamically in C++?

1) malloc

2) calloc

3) new

4) All of the above

Answer : Option 3

What will be the output of cout << (5 > 3) << endl;

1) 1

2) 0

3) True

4) False

Answer : Option 1

Which of the following can be used to define an array in C++?

1) int arr[10];

2) int arr();

3) int arr{10};

4) None of the above

Answer : Option 1

What will be the output of cout << (5 && 0) << endl;

1) 1

2) 0

3) 5

4) None of the above

Answer : Option 2

What is the output of cout << (7 / 2.0) << endl;

1) 3

2) 3.5

3) 4

4) None of the above

Answer : Option 2

Which of the following is not a valid C++ data type?

1) int

2) float

3) string

4) real

Answer : Option 4

What will be the output of cout << (10 - 3 * 2) << endl;

1) 4

2) 2

3) 8

4) None of the above

Answer : Option 1

What is the correct way to define a copy constructor?

1) MyClass(const MyClass &obj);

2) MyClass(MyClass obj);

3) MyClass(MyClass &obj);

4) None of the above

Answer : Option 1

Which of the following is used for commenting in C++?

1) //

2) /* comment */

3) Both 1 and 2

4) None of the above

Answer : Option 3

What is the output of cout << (10 % 3) << endl;

1) 3

2) 2

3) 1

4) 0

Answer : Option 3