Write a program in C++ using a vector to create the following output
Write a program in C++ using a
- Declare a vector named numbers - Don’t specify a size and don’t initialize with values.
Starting with 2, pushing these into the back of the vector: 2, 4, 6, 8, 10
|
The size of the list is now 5.
The vector capacity (array size) is 6.
The back element is: 10
The front element is: 2
Now deleting the value at the end of the list . . .
The size of the list is now 4.
|
After deleting, here is the list: 2, 4, 6, 8
Now swapping the first number with the last number.
After swapping, here is the list: 8, 4, 6, 2
Now inserting 0 at the beginning of the list.
After inserting, here is the list: 0, 8, 4, 6, 8
The size of the list is now 5.
The value of the third element (index 2) is: 4
Now removing all list items . . .
The size of the list is now 0.
The vector capacity (array size) is 6.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









