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
Make a list of at least 5 business ideas that interest you. Then explain which one you think is the best opportunity for you. Gi
SashulF [63]

Answer: Veterinarian

Explanation: Schooling would be interesting for my interest in animal's. The payment is good for the subject and placement you might be in but also you get to be around a bunch of weird animals lol

6 0
3 years ago
What is the music form for the song "Sunflower?
Leni [432]

Answer:

spiderman i believe. by post malone

Explanation:

4 0
3 years ago
Read 2 more answers
Thinking about the operations needed in these games, which game is likely to be one of the oldest games in the world?
erma4kov [3.2K]
I would say tag because it only involves touching
6 0
3 years ago
Read 2 more answers
Why is translator required?​
stich3 [128]

In Lanugange=Hi! translator is required because if you visit a different country and you don't know the language than a translator will help a lot

In computer=Hi! It translates a high level language program into machine language program the central processing unit (CPU) can understand.

5 0
2 years ago
Read 2 more answers
A document's margin is __________.
sleet_krkn [62]

Answer:

A. the blank area around an element in a document

Explanation:

Margin allows to add blank space on the Top, bottom ,right and left side of your element

4 0
3 years ago
Other questions:
  • What key combination in excel takes you back to the first cell
    7·1 answer
  • How to create a delete button in Python?
    15·1 answer
  • ​​most code division multiple access (cdma) networks conform to ____________ , created by the telecommunications industry associ
    10·1 answer
  • What type of hardware enable user to interact with a computer
    15·1 answer
  • Someone pleaseee answer my last question i just posted ;-;
    6·2 answers
  • Can someone help me with my homework?
    7·1 answer
  • Freeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee points
    14·2 answers
  • Please help!!! I am very confused about this question!
    10·1 answer
  • Why are control components necessary in traditional software and generally not required in object-oriented software?​
    11·1 answer
  • Peyton is taking a part-time job to earn some extra money. Every week the manager will provide a list of tasks and the number of
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!