lambogarcia3 lambogarcia3
  • 15-05-2021
  • Computers and Technology
contestada

Assume you define a vector in the following way:

vector vec;

Assign the value 10 to the first element of this vector. What is the statement you would use?

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 20-05-2021

Answer:

vec[0].push_back(10)

Explanation:

Given

Declaration: vector <int> vec

Required

Assign 10 to the first element

This can be done using the push_back keyword.

The syntax is:     vectorname[position].push_back(value);

In this case:

vectorname = vec

position = 0 i.e. first element

value = 10

So, we have:

vec[0].push_back(10)

Answer Link

Otras preguntas

How many chromosomes does each new cell contain after mitosis if the original cell had 52 original cell chromosomes
How do plant populations in a community change over time?
Describe how the Hawaiian Islands were formed and how they are evidence for mantle plumes.
Describe how the Hawaiian Islands were formed and how they are evidence for mantle plumes.
How do plant populations in a community change over time?
X=5y.          y=10x+20 Help please
Describe how the Hawaiian Islands were formed and how they are evidence for mantle plumes.
What biome is New Caledonia considered?
A grade has 81 girls and 72 boys. The grade is spilt into groups that have the same ratio of boys to girls as the whole grade. How many girls are in a group tha
X=5y.          y=10x+20 Help please