Answer:
following are the code this question:
numMatches = 0; //assign value 0 in numMatches variable
for (i = 0; i < NUM_VALS; i++) //defining a loop that count and match value inside the loop
{
if (userValues[i] == matchValue) //define if block that check value
{
++numMatches; //increment value of numMatches by 1
}
}
Step-by-step explanation:
Description of the above code as follows:
- In the above code, we assign a value, that is 0 in the "numMatches" variable, in the next step, a for loop is declare, that will count all array value.
- Inside the loop a conditional statement is used, that matches "matchValue" to the array "userValues".
- In this if the given value is matched, it will first increment the value of "numMatches".