Question: Given an integer vector myVector with three elements and an input integer addSize, resize myVector to add addSize elements to the vector. After resizing myVector,

 Given an integer vector myVector with three elements and an input

Given an integer vector myVector with three elements and an input integer addSize, resize myVector to add addSize elements to the vector.

After resizing myVector, the new elements are initialized with the default value 1.

Ex: If the input is 2, then the output is:

Start 7 6 5 End

Start 7 6 5 1 1 End

Note: Assume that addSize is a non-negative integer.

-------------------------------------

#include #include using namespace std;

int main() { vector myVector(3); int initMyVectorSize = myVector.size(); int addSize; int i;

myVector.at(0) = 7; myVector.at(1) = 6; myVector.at(2) = 5;

cin >> addSize;

cout

// ENTER CODE HERE IN C++ (THANK YOU)

for (i = 3; i

cout

return 0; }

Given an integer vector myVector with three elements and an input integer addSize, resize myVector to add addSize elements to the vector. After resizing myVector, the new elements are initialized with the default value 1. Ex: If the input is 2, then the output is: Start 765 End Start 76511End Note: Assume that addSize is a non-negative integer

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!