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}.
2 answers:
#include <iostream> #include <vector> #define NUM_GUESSES 3 int main() { std::vector<int> userGuesses; for (int i = 0, input; i < NUM_GUESSES; i++) { std::cin >> input; userGuesses.push_back(input); } }
Answer:
The solution code is written in C++.
vector<int> userGuesses; int NUM_GUESSES = 3; int i; int inputNum; for(i = 1; i <= NUM_GUESSES; i++){ cin>>inputNum; userGuesses.push_back(inputNum); } Explanation:
By presuming there is a vector, userGuesses and the NUM_GUESSES is 3 (Line 1 - 2).
Next we can create a for-loop that will run for NUM_GUESSES round of iterations. In each iteration, we use cin to get an input number and then use push_back method to add the input number to the userGuesses vector (Line 7 - 10).
You might be interested in
Put a code or security system on or a very secure password
Hope this helps...
Answer:
Fair use
Explanation:
I don't know if this is correct but Its the best option.
Answer:
B. Archery
Explanation:
the art, practice, or skill of shooting with bow and arrow
Does applications make sense <span />
Answer:
4
Explanation:
The mean is the sum divided by the count of numbers, so 36/9 = 4