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
A 0.5 kg block of aluminum (caluminum=900J/kg⋅∘C) is heated to 200∘C. The block is then quickly placed in an insulated tub of co
Genrish500 [490]

Answer: When 1.0kg of aluminium block is used, the final temperature of the mixture will be T = 36.2∘C

If 1.0kg copper block is used, T of the mixture will be = 17.4∘C

If 100g (0.1kg) of ice at 0∘C is used, T will be = 64.9∘C

If 25g (0.025Kg) of ice is used, T will be= 147.1∘C

Explanation:

H = mcΘ

heat lost by block = heat gained by water

m₁c₁Θ₁ = m₂c₂Θ₂ where m₁ is mass of aluminium, m₂ is mass of water, c₁ is cAluminium, c₂ is cWater, Θ₁ is temperature change for aluminium, Θ₂ is temperature change for water.

0.5*900*(200-20) = m₁*4186*(20-0)

m₁ = 450*180/83270

<em>m₁ = 0.973kg</em>

<em>when 1.0kg of aluminium block is used, the final temperature of the mixture will be </em><em>T</em>

heat lost by block = heat gained by water

1.0*900*(200-T) = 0.973*4186*(T-0)

180000 - 900T = 4073T

4973T = 180000

T = 180000/4973 = 36.2∘C

<em>If 1.0kg copper block is used, T of the mixture will be</em>

heat lost by block = heat gained by water

1.0*387*(200-T) = 0.973*4186*(T-0)

77400 - 387T = 4073T

4460T = 77400

T = 77400/4460 = 17.4∘C

<em>If 100g (0.1kg) of ice at 0∘C is used, T will be</em>

<em>heat lost by block = heat gained by water + heat used in melting ice to form water at 0∘C</em>

heat used in melting 0.1kg of ice, H = ml, where l= 33600J/Kg

0.5*900*(200-T) = 0.1*4186*(T-0) + 0.1*33600J/Kg

90000 - 450T =  418.6T + 33600

418.6T + 450T = 90000 - 33600

868.6T = 56400

T = 56400/868.6 = 64.9∘C

If 25g (0.025Kg) of ice is used, T will be

0.5*900*(200-T) = 0.025*4186*(T-0) + 0.025*33600J/Kg

90000 - 450T =  104.65T + 8400

104.65T + 450T = 90000 - 8400

554.65T = 81600

T = 81600/554.65 = 147.1∘C

7 0
3 years ago
Find the weight of an object with mass 80 kg on the moon ( g = 1.6 m/s^2)
SpyIntel [72]

Answer:

80kg = 133 Newtons I'm pretty sure this is right.

5 0
2 years ago
Select the volume units that are greater than one liter.
Andreas93 [3]
A.) kiloliter. 1 kiloliter = 1,000 liters
c.) megaliter. 1 megaliter =  1,000,000 liters


hope this helps
5 0
2 years ago
Read 2 more answers
What do neon,oxygen and nitrogen have in common?
julsineya [31]
Their Period number is common means their "Principal Quantum Numbers" are same

Hope this helps!
7 0
3 years ago
Hanna tosses a ball straight up with enough speed to remain in the air for several seconds?
olga_2 [115]
A) the velocity is 0 m/s
3 0
3 years ago
Read 2 more answers
Other questions:
  • Technician a says that some passenger vehicles use more than one evaporator. technician b says that some passenger vehicles use
    7·1 answer
  • On June 23, which area will sunlight hit more directly?
    8·1 answer
  • Jack pushed and pushed, but no matter how hard he tried, the refrigerator would not budge! What is the BEST explanation of what
    12·2 answers
  • The unit of length most suitable for measuring the thickness of a cell phone is a
    13·1 answer
  • Which part of an atom is gained, lost, or shared during a chemical reaction? Electron
    14·2 answers
  • The law of conservation of mass is important in ecology because _________.
    5·1 answer
  • According to Newtons third law of motion when one object exerts a force on a second object what is true about the forces?
    14·1 answer
  • What is the frequency of this wave? <br><br>can someone pls explain and answer ​
    12·1 answer
  • A cog system on the beginning segment of a roller coaster needs to get 29 occupied cars up a 120-m vertical rise over a time int
    14·1 answer
  • Find the volume of a fish tank 105cm long 75cm wide and 80.5cm high using scientific notation
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!