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
IN C++ PLEASE!!! Read integers from input and store each integer into a vector until -1 is read. Do not store -1 into the vector
ololo11 [35]
#include
#include
using namespace std;

int main(){

int input[] = {-19, 34, -54, 65, -1};
std::vector voutput:
std::vector vinput (input, input + sizeof(input) / sizeof(int) );

for (std::vector::iterator it = vinput.begin(); it != vinput.end(); ++it)
if(*it > 0) voutput.insert(voutput.begin(), *it);
for(std::vector::iterator it = voutput.begin(); it < voutput.end(); ++it)
std::cout << *it << ‘\n’ ;

return 0;
}
6 0
3 years ago
Which of the following is the best way to add a lengthy explanation to Excel data without being limited to cell sizes and restri
trapecia [35]

Answer:

B

Explanation:

Which of the following is the best way to add a lengthy explanation to Excel data without being limited to cell sizes and restrictions? A. Adding a chart object B. Adding an Access object C. Adding a Word object D. Adding an Excel object microsoft word

Answer: B

6 0
3 years ago
Which is the 6-by6 rule for presentations
marin [14]

Answer:

You might already be familiar with the 6×6 rule. This presentation rule suggests that you should include no more than six words per line and no more than six bullet points per slide. The goal is to keep your slide from being so dense and packed with information that people don't want to look at it

7 0
4 years ago
I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
Oksana_A [137]

Answer:

Pseudocode:

import random

fetch user input on a lucky number

insert input into variable - "response"

new variable, random = randint

condition to check wheather random is our response

display results

Python Code:

import random

def main():

response = int(input("Guess my lucky number, its between 1 and 100: "))

lucky_number = random.randint(1,100)

if response == lucky_number:

print(f"Wow you're right, it is {lucky_number}")

else:

print("Sorry, Try Again")

main()

Reminder:

intended for python3 as i included the format f

also it could be done without the import, just manually insert a number

i'll leave the post mortum to you

Explanation:

3 0
3 years ago
Is a collection of computers and other devices that are connected in order to enable users to share hardware, software, and data
antoniya [11.8K]
That would be a Network.
8 0
3 years ago
Other questions:
  • When entering a function or formula in a cell, which is the first character you must type?
    15·2 answers
  • Which of the following statements about relays is correct? A. A relay is a type of rheostat. B. A normally closed relay closes a
    6·2 answers
  • Proper __ management is essenciales for meeting project deadlines​
    11·1 answer
  • who will follow me on tiktok and like all my videos? if you do ill give branlist and give u a shoutout and you can enter my big
    15·1 answer
  • What is the process that creates a shortcut on your taskbar?
    14·2 answers
  • Why is page formatting important??​
    10·2 answers
  • Write a basic notation for
    8·1 answer
  • Decomposition is
    5·1 answer
  • _______ is the use of software to assist in the creation, analysis, and modification of the design of a component or product.
    9·1 answer
  • program that initialises a vector with the following string values: “what” “book” “is” “that” “you” “are” “reading”.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!