Hai D. answered 04/13/20
Software Engineer at Microsoft with MS in Computer Science
1 #include <iostream>
2 using namespace std;
3
4 int main() {
5 const int NUM_VALS = 4;
6 int userValues[NUM_VALS];
7 int i;
8 int matchValue;
9 int numMatches = -99; // Assign numMatches with 0 before your for loop
10
11 cin >> matchValue;
12 for (i = 0; i < NUM_VALS; ++i) {
13 cin >> userValues[i];
14 }
15
16 /* Your solution goes here */
17 numMatches = 0;
18 for (i = 0; i < NUM_VALS; ++i) {
19 if(userValues[i] == matchValue) {
20 numMatches++;
21 }
22 }
23
24 cout << "matchValue: " << matchValue << ", numMatches: " << numMatches << endl;
25
26 return 0;
27 }
Please like, if you see it is a good solution