Oscar A.

asked • 04/12/20

Write a for loop to populate vector userGuesses with NUM_GUESSES integers.

Write a for loop to populate vector userGuesses with NUM_GUESSES integers. Read integers using cin. Ex: If NUM_GUESSES is 3 and user enters 9 5 2, then userGuesses is {9, 5, 2}.


#include <iostream>

#include <vector>

using namespace std;


int main() {

const int NUM_GUESSES = 3;

vector<int> userGuesses(NUM_GUESSES);

unsigned int i;


/* Your solution goes here */


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

cout << userGuesses.at(i) << " ";

}


return 0;

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.