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.

How the size of a vector increases once it is full?

A. Vector increases its capacity one by one
B. Vector doubles its capacity after it is full
C. Vector increases its capacity by half of its previous size
D. Vector increases its capacity by a constant factor
Answer» C. Vector increases its capacity by half of its previous size
2.

Which function is used to get the total capacity of a vector?

A. v.size()
B. v.capacity()
C. v.max_size()
D. v.no_of_elements()
Answer» C. v.max_size()
3.

Which of the following function is used to get the actual number of elements stored in vector?

A. v.size()
B. v.capacity()
C. v.max_size()
D. v.no_of_elements()
Answer» B. v.capacity()
4.

Which is the following is syntactically correct for vector<int> v?

A. vector &lt;int&gt; :: const_iterator itr = v.rbegin();
B. vector &lt;int&gt; :: reverse_iterator itr = v.begin();
C. vector &lt;int&gt; :: iterator itr = v.begin();
D. vector &lt;int&gt; :: iterator itr = v.cbegin();
Answer» D. vector &lt;int&gt; :: iterator itr = v.cbegin();
5.

What is the difference between begin() and rbegin()?

A. both are the same
B. begin() returns an iterator to the first element and rbegin() returns an iterator to an element kept at the end of the vector
C. begin() returns an iterator to first element whereas rbegin() returns constant iterator to first element
D. begin() returns returns first element rbegin() returns void
Answer» C. begin() returns an iterator to first element whereas rbegin() returns constant iterator to first element
6.

What is the difference between begin() and cbegin() in vectors?

A. both are same
B. begin() returns iterator to first element and cbegin() returns iterator to last element
C. begin() returns an iterator to first element whereas cbegin() returns constant iterator to first element
D. begin() returns returns first element cbegin() returns void
Answer» D. begin() returns returns first element cbegin() returns void
7.

Which of the following(s) can be used to access the last element of a vector v?

A. v.end()
B. v.cend()
C. both v.end() and v.cend()
D. vectors do not have a function to access the last element
Answer» E.
8.

Which of the following(s) can be used to access the first element of a vector v?

A. v.begin()
B. v.cbegin()
C. v[0]
D. all of the mentioned
Answer» E.
9.

Which of the following header file is needed to use vectors in your program?

A. &lt;array&gt;
B. &lt;vector&gt;
C. &lt;containers&gt;
D. &lt;stdio&gt;
Answer» C. &lt;containers&gt;
10.

What are the vectors?

A. Arrays with dynamic size
B. Arrays with different types of elements
C. Same as array classes
D. Arrays with static size but use template classes
Answer» B. Arrays with different types of elements