QUESTION 1 Assume that the following statements have been executed: vector a, b(
ID: 3717721 • Letter: Q
Question
QUESTION 1
Assume that the following statements have been executed:
vector a, b(5), c(5, 1), d(5);
d.push_back(77);
d.push_back(88);
The output of the following:
d.pop_back();
for (int j = 0; j < d.size(); j++)
cout << c[j] << ' ';
is: __________________________
10 points
QUESTION 2
Assume that the following statements have been executed:
vector a, b(5), c(5, 1), d(5);
d.push_back(77);
d.push_back(88);
The capacity of b is and its size is .
10 points
QUESTION 3
Assume the declarations:
vector xValue;
vector number(5, 1);
The content of the vector after the following statement is executed:
for (int j = 0; j < 5; j++)
if (j % 2 == 0)
number.push_back(2 * j);
else
number.push_pack(2 * j + 1);
is:________________________
10 points
QUESTION 4
Assume that the following statements have been executed:
vector a, b(5), c(5, 1), d(5);
d.push_back(77);
d.push_back(88);
then:
d.end() returns an iterator positioned ___________ in d.
10 points
QUESTION 5
Assume that the following statements have been executed:
vector a, b(5), c(5, 1), d(5);
d.push_back(77);
d.push_back(88);
The capacity of c is and its size is
Explanation / Answer
1. The output of the following for loop:
d.pop_back() : 88
for loop output:
1 1 1 1 1
So, it will print:
88 1 1 1 1 1
2. The capacity of b is 5 and its size is 0.
3. 1, 1, 1, 1, 10, 3, 4, 7 8
4. d.end() returns an iterator positioned 1 in d.
5. The capacity of c is 5 and its size is 5.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.