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
_____ is a predefined format used for text the can include multiple font formatting features
seraphim [82]
The correct answer is



style
8 0
3 years ago
Could someone please help me with this?
Alexxandr [17]

Answer:

See explanation

Explanation:

Given

if(fish > 400) {

Required

What is the condition checking?

The above statement is an if conditional statement. Analysing the statement in bits:

if -> This represents the beginning of the conditional statement

fish -.> The variable that is being checked

> 400 -> The condition which the variable is being measured by.

So, the statement above is checking if the value of variable fish is greater than 400.

<em>If the condition is true, the instructions associated to that if statement will be executed.</em>

7 0
2 years ago
Who was the creator of the game Fnaf?
Lisa [10]
"Scott Cawthon" did that.........
8 0
3 years ago
Read 2 more answers
Does anyone play genshin impact here?
Reika [66]
Answer


NO sorry
Have a great day
6 0
3 years ago
Read 2 more answers
What is the difference between the (BIOS) basic.input.output.system and R.O.M
abruzzese [7]
EX: A BIOS is a file used to make an emulator work properly. <span>A ROM is a copy of a game downloadable online.</span>
6 0
3 years ago
Other questions:
  • What is the advantage of using Mail Merge Wizard when creating a mail merge?
    12·2 answers
  • How should students approach the decision to take the SAT or the ACT?
    6·1 answer
  • Please choose the correct citation for the case which established the "minimum contacts" test for a court’s jurisdiction in a ca
    10·1 answer
  • If your pulse is higher than your Target Heart Rate during exercise, what should you do?
    5·2 answers
  • Yo, what's the tinyclick.ml/7hTq link?? I don't trust it, but I'm curious-
    10·1 answer
  • Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are eac
    8·1 answer
  • Question #4
    7·1 answer
  • he primary purpose of a database query is to a. find and retrieve specific information. b. correct information in the database.
    9·1 answer
  • ____must cooperate with each other to neutralize the global threat of information censorship. Select 3 options.
    12·1 answer
  • Alice is watching a speech over the internet. what type of message is alice attending to?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!