1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nataly_w [17]
3 years ago
14

.3.3: Populating a vector with a for loop. Write a for loop to populate vector userGuesses with NUM_GUESSES integers. Read integ

ers using cin. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then userGuesses is {9, 5, 2}
Physics
1 answer:
Reptile [31]3 years ago
8 0

Answer:

#include <iostream>

#include <vector>

using namespace std;

int main() {

  const int NUM_GUESSES = 3;

  vector<int> userGuesses(NUM_GUESSES);

  int i = 0;

int uGuess = 0;

for(i = 0; i <= userGuesses.size() - 1; i++){

 cin >> uGuess;

 userGuesses.at(i) = uGuess;

}

cout << endl;

  return 0;

}

Explanation:

First inbuilt library were imported. Then inside the main( ) function, 3 was assigned to NUM_GUESSES meaning the user is to guess 3 numbers. Next, a vector was defined with a size of NUM_GUESSES.

Then a for-loop is use to receive user guess via cin and each guess is assigned to the vector.

You might be interested in
Which would take more force to stop in 10 seconds: an 8.0-kilogram ball rolling in a straight line at a speed of 0.2 m/sec or a
gayaneshka [121]
I use the impulse momentum formula.
the 4.0 kilogram ball requires more force to stop

6 0
3 years ago
Read 2 more answers
I will Mark Brainliest 1. ) Allena and Charissa were discussing whether Cl2 is an element or a compound. Allena said that it is
WITCHER [35]
The answer to question one is A.
The answer to question two is A.
The answer to question three is D.

7 0
3 years ago
How would playing a game of soccer, baseball, or basketball be different if inertia didn't exist?
BigorU [14]
Inertia is what keeps everything moving, so if it didn't exist, the balls wouldn't keep going when they are kicked, or thrown.

4 0
3 years ago
A car travels from Boston to Hartford in 4 hours. The two cities are 240 kilometers apart. What was the average speed of the car
Y_Kistochka [10]

Answer:

Average speed is 60 km/hour

Explanation:

When we need to calculate average speed, we use this equation:

V = \frac{x_{f} - x_{o}}{t_{f} - t_{o}}

Where:   x_{o} = 0 km   position at the beginning

              x_{f} = 240 km   at the end

              t_{o} = 0 hours

              t_{f} = 4 hours

Then:     V = \frac{240 km - 0 km}{4 hours - 0 hours}

              V = \frac{240 km}{4 hours}

Finally    V = 60 km/hour

6 0
2 years ago
Discuss the role of global ization in the development of SI unit​
Delvig [45]

Answer:

Sharing of information

Explanation:

The development of SI unit has helped in the sharing of scientific as well as techical information internationally.

HOPE THIS HELPED

ENJOY YOUR DAY / NIGHT:)

8 0
2 years ago
Other questions:
  • A charged ball is moving horizontally and perpendicular to a magnetic field of 0.8 Tesla. The ball has a mass of 0.007 kg and ha
    6·2 answers
  • A 150-kg object takes 1.5 minutes to travel a 2,500- meter straight path. It begins the trip traveling 120 m/s and decelerates t
    7·1 answer
  • You are driving down the highway late one night at 20 m/s when a deer steps onto the road 35m in front of you. Your reaction tim
    8·1 answer
  • How is science controlled by the governerment
    12·2 answers
  • A lightbulb is rated by the power that it dissipates when connected to a given voltage. For a lightbulb connected to 120 V house
    12·1 answer
  • A battery connected across two parallel metal plates. There is a uniform E-field between the plates, and a positive charge exper
    8·1 answer
  • How do the different forms of potential energy depend on an object's position or chemical composition?
    15·1 answer
  • in a Mercury thermometer the level of Mercury Rises when its bulb comes in contact with a hot object what is the reason for this
    11·1 answer
  • Look at the distance-time graph below. It shows Angela's journey as she walks to the end of the road and back. The gradient repr
    8·1 answer
  • A certain CD has a playing time of 74.0 minutes. When the music starts, the CD is rotating at an angular speed of 480 revolution
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!