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
madreJ [45]
3 years ago
15

Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If user

Values is {2, 1, 2, 2} and matchValue is 2 , then numMatches should be 3. Your code will be tested with the following values:
matchValue: 2, userValues: {2, 1, 2, 2} (as in the example program above)
matchValue: 0, userValues: {0, 0, 0, 0}
matchValue: 10, userValues: {20, 50, 70, 100}
#include
#include
using namespace std;
int main() {
const int NUM_VALS = 4;
int matchValue;
unsigned int i;
int numMatches = -99; // Assign numMatches with 0 before your for loop
vector userValues(NUM_VALS);
cin >> matchValue;
for (i = 0; i < userValues.size(); ++i) {
cin >> userValues.at(i);
}
/* Your solution goes here */
cout << "matchValue: " << matchValue << ", numMatches: " << numMatches << endl;
return 0;
}
Computers and Technology
1 answer:
Sedbober [7]3 years ago
3 0

Answer:

Replace /* Your solution goes here */ with:

cin>>matchValue;

numMatches = 0;

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

if(matchValue == userValues.at(i))

{

numMatches++;

}

}

Explanation:

This line gets input for matchValue

<em>cin>>matchValue; </em>

This line initializes numMatches to 0

<em>numMatches = 0; </em>

The following iteration checks for the number of matches (numMatches) of the matchValue

<em>for (i = 0; i < userValues.size(); ++i) { </em>

<em>if(matchValue == userValues.at(i)) </em>

<em>{ </em>

<em> numMatches++; </em>

<em>} </em>

<em>} </em>

<em>See Attachment for full source code</em>

Download cpp
You might be interested in
What tips or techniques should you keep in mind when shooting photographs on a rainy day?
SashulF [63]
Simple: Keep your camera protected from the rain

Here are some tips for photographing during rainy day: 1) Use image stabilization or tripod.
2) Choose a larger aperture.
3) Change the object on which you focus.
4) Have a well-defined center of interest.
5) Review all images.
6) Use exposure compensation.

7 0
3 years ago
Know when the double, int, String, and char data types are best used. Example: I would store a social security number in a strin
lidiya [134]
A double is best used for numbers that are real, as in they have a decimal. Int is best used for numbers that are whole, as in no decimal. Strings are best used, as in the example you gave, when you have to represent a piece of information that isn’t strictly numbers
4 0
3 years ago
How it/computing has impacted on engineering? <br><br> I need seven answers please help !
Marina CMI [18]

Answer:

1. they are now able to make,design and test designs created

2.with the use of a computer , work is done at a very fast rate

3. with a computer in the field of engineering, mistakes don't occur frequently.

5 0
3 years ago
Carbon copy others who are..
My name is Ann [436]

Answer:

Is it Multiple Choice Question?

5 0
3 years ago
Read 2 more answers
Someone please help fast! I’m taking the test rn and I don’t understand this!!!!!!
andrezito [222]

Answer:

the mistake that was made by allen is that he was not suppose to hire a highly proficient technician to install the heating and cooling system in the granary.

7 0
3 years ago
Other questions:
  • What is the fastest way to move data over long distances using the internet, for instance across countries or continents to your
    13·1 answer
  • You are purchasing several PC systems that will be used as thin clients in a large organization. Which hardware selection criter
    9·1 answer
  • What does FLUX do when soldering an electrical joint?
    13·2 answers
  • Based on the following quote from Leonardo Da Vinci, what would be his definition of a fine artist? “Principles for the Developm
    11·2 answers
  • What are the main security weaknesses of coaxial cable, twisted pair cable, and fiber optic cable? How might the router itself b
    8·1 answer
  • Explain the term creating in word processing​
    12·1 answer
  • What does this mean? And how did I get it?
    12·2 answers
  • If consumers start to believe they need a product, what is likely to happen
    15·1 answer
  • Ali has created a small program in Python, but he wants to store his data in a multi-dimensional array. He would like to use adv
    8·1 answer
  • What is the basic body structure of html.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!