consider the testPIN function used in Program 7-21. For convenience, we have rep
ID: 3647856 • Letter: C
Question
consider the testPIN function used in Program 7-21. For convenience, we have reproduced the code for you below:bool testPIN(int custPIN[], int databasePIN[], int size) {
for (int index = 0; index < size; index++) {
if (custPIN[index] != databasePIN[index])
return false; // We've found two different values.
}
return true; // If we make it this far, the values are the same.
}
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.
Explanation / Answer
bool testPIN(int custPIN[], int databasePIN[], int size) { int count; count=countMatches(custPIN,databasePIN,size); if(count==size) return true; else return false; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.