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

Which describes a natural environment with the greatest biodiversity? A. 10 red squirrels, 20 bristlecone pine trees B. 55 bristlecone pine trees, 30 snowsho
what are some ways to reduce flooding?
How do I solve this?
The logical presentation of smoothly connected ideas is known as a. formality. b. an essay. c. conjunction. d. coherence.
What is the frequency of a wave having a wavelength of 6.9x10
When you are paddling a canoe, you push the water backwards with your paddle, which in turn will push you forward. Which law of motion is being described in th
What does the passage suggest about richard nixon's defeat in the 1960 presidential election?
How long has universal health care been around?
I am stuck on this question. "Viruses are considered to be which of the following?" (This is multiple choice)
Discuss how you would talk with a patient who has expressed legitimate fears about having health information in electronic form