Answer:
Written in C++
int matches(int arr1[], int arr2[], int k) {
int count = 0;
int length = k;
for(int i =0; i<length; i++) {
if(arr1[i] == arr2[i]) {
count++;
}
}
return count;
}
Explanation:
This line defines the function
int matches(int arr1[], int arr2[], int k) {
This line initializes count to 0
int count = 0;
This line initializes length to k
int length = k;
This line iterates through the array
for(int i =0; i<length; i++) {
The following if statement checks for matches
if(arr1[i] == arr2[i]) {
count++;
}
}
This returns the number of matches
return count;
}
See attachment for complete program