Explore topic-wise MCQs in C++ Programming.

This section includes 10 Mcqs, each offering curated multiple-choice questions to sharpen your C++ Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following Operator cannot be used with pairs?

A. +
B. ==
C. =
D. !=
Answer» B. ==
2.

What happens if a pair is not initialized?

A. Both first and second part is initialized to zero or null
B. Both first and second part is initialized a garbage value
C. First is initialized to zero or null and second is initialized a garbage value
D. Second is initialized to zero or null and first is initialized a garbage value
Answer» B. Both first and second part is initialized a garbage value
3.

Which of the following is correct way of copying the values of pair p1 into other pair p2?

A. pair <type,type> p2 = p1;
B. pair <type,type> p2(p1);
C. Both pair <type,type> p2 = p1; and pair <type,type> p2(p1);
D. Pair <int,int> p2.copy(p1);
Answer» D. Pair <int,int> p2.copy(p1);
4.

Which of the following is the correct syntax of accessing the second element of a pair p?

A. p.first
B. p.second
C. p[0]
D. p[1]
Answer» C. p[0]
5.

Which of the following is the correct syntax of accessing the first element of a pair p?

A. p.first
B. p.second
C. p[0]
D. p[1]
Answer» B. p.second
6.

Which operator is used to access the first or second element of a pair?

A. ->
B. .
C. *
D. []
Answer» C. *
7.

Which of the following operations can be performed on a pair?

A. Assignment of pairs
B. Copying of one pair to another
C. Comparison of two pairs
D. All of the mentioned
Answer» E.
8.

Which of the following is the correct syntax of using pair p?

A. pair <type,type> p;
B. pair p <type,type>;
C. pair [type,type] p;
D. pair p [type,type];
Answer» B. pair p <type,type>;
9.

Which header file is required to use pair container in your program?

A. <algorihtm>
B. <utility>
C. <pair>
D. <utitityPair>
Answer» C. <pair>
10.

What is a pair?

A. Container consisting of two data elements of the same type
B. Container consisting of two data elements of different type
C. Container consisting of one header and two data elements of the same type
D. Container consisting of two data elements can have the same or different type
Answer» E.