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 best describes communication? the willingness to give up something to reach a goal the desire to do the best you possibly can the process of sharing
how do i solve this???? help please
Tim ate 1/6 of the brownies and Abigail ate 1/8. How many all together?
is 'the twinkling eyes of a deer in the forest' a phrase?
The lenth of the room is 3 times the width and the total area of the room is 12 square meters. what is the length of the living room
How do horizontal winds cause air to rise or sink?
The mass in a pendulum clock completes one complete swing in 1.20 s . part a what is the length of the rod?
Work with a partner. you buy a shirt that is on sale for 30% off. you pay $22.40. your friend wants to know the original price of the shirt. how can your friend
What was a strong influence on elvis presley?
Ann cut an apple into 4 equal pieces. she gave 1 piece to her sister. what fraction of the apple did anna give to her sister?