Question: C++ multiple choice problems 1)The size of a vector: a)must be a constant. b) must be a variable. c)may be omitted when declaring the vector.

C++ multiple choice problems

1)The size of a vector:

a)must be a constant.

b) must be a variable.

c)may be omitted when declaring the vector.

d)is not known and is not relevant.

e)is established on declaration and cant be changed.

2)Which of these will fill a vector with 100 random numbers:

a) for(int i=0;i<100;i++) //Declared: V[i] = rand(); // vector V(100);

b)for(int i=0;i<100;i++) // Declared: V.push_back(rand()); // vector V;

c)i=0; while(i<100) //Declared: { // vector V; V.push_back(rand()); i++; }

d) All of them

e)None of them

3) Given the following code: vector text(2); text.push_back(XXXX); which element of the vector will get set toXXXX?

a)text[0]

b)text[1]

c)text[2]

d)text[3]

e)None, there is a syntax error

4)To declare a vector of strings, the correct definition is:

a)vector names[];

b)vector names;

c)string names();

d)string vector names[];

e)vector() names;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!