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 the underlined words in the sentence? On the next cloudless night, go outdoors and look at the sky. A. compound verb B. simple predicate
what happens in the arctic circle during summer? why?
describe shakespeare's theatre?
what happens in the arctic circle during summer? why?
Why did representative government grow in the colonies?
Which of the following qualities are NOT associated with mineral luster? A. dull B. rough surface C. metallic D. opaque
A swimmer swims 3/5 the width of a river at one velocity, then swims the remainder of the river at half her initial velocity. What was the average speed across
The money used in jordan is called dinar ,The exchange rate is $3 to 2 dinar how many dollars would you recieve if you exchanged 22 dinar ?
is 5/8 closer to 0 1/2 or 1 ?
How long will it take to drive 200 miles if the driver's average speed is 55 mph?