Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Questions QUESTION 1 Assume the declarations: vector xValue; vector number(5

ID: 3783894 • Letter: C

Question

C++ Questions

QUESTION 1

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 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 output of the following:

d.pop_back();

for (int j = 0; j < d.size(); j++)

  cout << c[j] << ' ';

is: __________________________

10 points   

QUESTION 3

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 d is  and its size 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);

The capacity of a is  and its size is .

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 b is  and its size is .

Explanation / Answer

Question 1

output is 1,1,1,1,1, 0,3,4,7,8 this sequence store the element inside vector

because number(5,1) means 5 int with one value

question 2

ans is 1

because c(5,1) means 5 int with one value and

vector d contains 2 value and one value is pop so only one time loop will executed

  Question 3

capacity is d=10 and size is 7

question 4

The Capacity is zero and size is zero

both are zero

Question 5;

The capacity is 5 and size 5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote