Hi there! I was wondering if I could get help with some C++. Here is the question:
Again, consider the testPIN function used in Program 7-21. For convenience, we have reproduced the code for you below.
Rewrite the function body of this function so that instead of using iterating through the elements of the parallel arrays , it returns true or false by calling countMatches the function defined in the previous exercise (10988), and checking its return value.
Here is the code for the question:
bool testPIN(int custPIN[], int databasePIN[], int size)
{
for (int index = 0; index < size; index++)
{
if (custPIN[index] != databasePIN[index])
return false;
}
return true;
}
Here is the function countMatches:
int countMatches(int custPIN[], int databasePIN[], int size)
{
int matches = 0;
for (int index = 0; index < size; index++) {
if (custPIN[index] == databasePIN[index])
matches++;
}
return matches;
}
What I dont understand is, how do they need me to check the value for matches without iterating through each value of testPIN?