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

What does 'Machen' mean in English?
What is the approximate volume of a cone with a height of 12 in. and radius of 9 in.? Use 3.14 to approximate pi, and rexpress your final answer to the nearest
what is the best way to overcome imagined risks
Which nation was the scene of widespread violence in 1989 when government troops were called out to put down a peaceful demonstration by thousands of people who
Write a brief desperation for each of newtons three laws
Which of the following would be the most important change in most women in saudi arabia? a. new styles of hijabs and sharshafs b. the right to vote c. the abili
what is the answer for 7w=87;w=12
William Penn referred to his colony as a “Holy Experiment” because
What is the net displacement of the particle between 0 seconds and 80 seconds?
explain why the above relationship is important in one's life