Which assigns the vector's first element with 99? vector myVector(15);
A. myVector.at(0) = 99;
B. myVector.at(14) = 99;
C. myVector.at(15) = 99;
D. myVector.at(16) = 99;

Answer :

The first element of a C++ vector is accessed using index 0, so the correct answer to assign the number 99 to the first element is A. myVector.at(0) = 99.Therefore the correct option is A.

To assign the value 99 to the first element of a vector in C++, you need to access the element at index 0, since vectors in C++ are zero-indexed. The correct way to do this using the given options is:

A. myVector.at(0) = 99;

Option B assigns 99 to the last element (index 14) of the vector since it has 15 elements. Options C and D would result in an out-of-range error, as they refer to non-existent elements beyond the vector's size.