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
b)vector
c)string
d)string vector names[];
e)vector()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started