Consider the testPIN function used in Program 7-21. For convenience, we have reproduced the code for you below. Modify this function as follows: change its type to int change its name to countMATCHES make it return the number of corresponding parallel elements that are equal
.
.
Click on the title for the solution
.
.
{
int matches=0;
for (int index = 0; index < size; index++) {
if (custPIN[index] == databasePIN[index])
matches++;
}
return matches;
}
.
Click on the title for the solution
.
.
This is the answer:
:
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;
}
Comments
Post a Comment