Which assigns the array's first element with 99?

A. int myVector[4]; myVector[1] = 99;
B. int myVector[4]; myVector[0] = 99;
C. int myVector[4]; myVector(-1) = 99;
D. int myVector[4]; myVector] = 99;

Answer :

the correct statement that assigns the array's first element with 99 is "myVector[0] = 99;". This is because arrays in C++ are zero-indexed, which means that the first element of the array is located at index 0, not 1.

To explain further, when the array "myVector" is created with the statement "int myVector[4];", it creates an array of 4 integer elements. By default, these elements are initialized with garbage values. The statement "myVector[1] = 99;" assigns the second element of the array (located at index 1) with the value 99, not the first element. Similarly, the statement "myVector(-1) = 99;" is not a valid syntax, and the statement "myVector] = 99;" contains a typo.

In conclusion, to assign the first element of the "myVector" array with the value 99, you should use the statement "myVector[0] = 99;".

To know more about garbage values visit:

https://brainly.com/question/29247275

#SPJ11