Learn C++ MCQs

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

What is the output of cout << (true && true) << endl;

1) 1

2) 0

3) true

4) false

Answer : 1

Which of the following operators is used for pointer dereferencing in C++?

1) &

2) *

3) ->

4) ::

Answer : *

What will be the output of cout << (4 == 5) << endl;

1) 1

2) 0

3) true

4) false

Answer : Option 2

Which of the following is a standard template library container in C++?

1) set

2) map

3) vector

4) All of the above

Answer : All of the above

What is the output of cout << (5 + 10 / 2) << endl;

1) 10

2) 15

3) 12

4) None of the above

Answer : 10

Which of the following is not a C++ loop construct?

1) for

2) foreach

3) while

4) do-while

Answer : foreach

What is the output of cout << (0 << 2) << endl;

1) 0

2) 2

3) 1

4) None of the above

Answer : Option 1

Which of the following is used for string concatenation in C++?

1) +

2) &

3) <<

4) None of the above

Answer : +

What is the purpose of the `volatile` keyword in C++?

1) To define a constant variable

2) To prevent optimization

3) To define a variable

4) None of the above

Answer : To prevent optimization

What is the output of cout << (5 & 3) << endl;

1) 3

2) 2

3) 1

4) None of the above

Answer : 1