c++
Write a function has Match that takes 3 parameters: 2 arrays of
strings and an int that represents the length of each array
The function returns true if at any position, the two arrays have
the same string, false if not.
For example: {"a", "b", "cat", "d"} and {"1", "2", "cat", "4"}
would match
Answer:
Explanation:
hasMatch function takes the 2 string arrays and the length of arrays.
then using a for loop, both the arrays are traversed on the same index at one time. If there is a match, the function returns true.
Otherwise at the end of the loop the function returns false.
Code:
#include <iostream>
using namespace std;
bool hasMatch(string a[], string b[], int n)
{
for (int i = 0; i < n; i++) {
if(a[i]==b[i])
return true;
}
return false;
}
int main()
{
string a[] = {"a", "b", "cat", "d"};
string b[] = {"1", "2", "cat", "4"};
cout<<hasMatch(a, b, 4);
return 0;
}
Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
c++ Write a function has Match that takes 3 parameters: 2 arrays of strings and an...
c++ program need help Write a function allBigger that takes 3 parameters: 2 arrays of floats and an int that represents the length of each array The function returns true if at every position, the value in the first array is strictly greater than the value in the 2nd array, false if not. For example: {1.3, 7.4, 2.51} and {1.0, 2.1, 3.2} would return false because 2.51 < 3.2
c++ program need help Write a function allBigger that takes 3 parameters: 2 arrays of floats and an int that represents the length of each array The function returns true if at every position, the value in the first array is strictly greater than the value in the 2nd array, false if not. For example: {1.3, 7.4, 2.51} and {1.0, 2.1, 3.2} would return false because 2.51 < 3.2
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
Write a function that takes an array of C-strings as a parameter and the number of elements currently stored in the array, and returns a single C-string pointer that is the concatenation of all C-strings in the array. Note: The function must take 2 parameters and return "char *". Any other ways will cause some deduction of points.
help ASAP
3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...
Define a function called DisplayMax that has 3 parameters: the first two parameters are parallel arrays of different types and the third argument is of type size_t representing the size of both arrays. The function DisplayMax must work when called with various types of actual arguments, for example string DisplayMax(string names[], int calories[], int size) or int DisplayMax(int calories[], float prices[], int size). (Parallel Arrays are two arrays whose data is related by a common index. For example: with the...
Write a program with a function named isEqualArr that accepts a pair of arrays of integers as parameters and returns true if the arrays contain the same elements in the same order. If the arrays are not the same length, your function should return false. For example, if the following arrays are declared: int[] arr1 = {10, 20, 30, 40, 50, 60}; int[] arr2 = {10, 20, 30, 40, 50, 60}; int[] arr3 = {20, 3, 50, 10, 68}; The...
c++ question need help Write a function pairWise that takes four parameters: two arrays of int and the size of the first array. The size of the first array is guaranteed to be exactly twice the size of the 2nd array The function takes each pair of integers from the first array and stores the product in the 2nd array. ex: if the first array is {2, 7, 3, 4}, then the second array will end up with {14, 12}
c++ question need help Write a function pairWise that takes four parameters: two arrays of int and the size of the first array. The size of the first array is guaranteed to be exactly twice the size of the 2nd array The function takes each pair of integers from the first array and stores the product in the 2nd array. ex: if the first array is {2, 7, 3, 4}, then the second array will end up with {14, 12}
More Practice: Writing Lists& Strings . Write a function average_ evens that takes a list of numbers as parameters, and adds all the even numbers together and returns their average using a list Example function call: print (average_evens (I-2, -3, 4, 0, 1, 2,3 Outputs: 0 Write a function match that takes two strings as a parameter and returns how many letters the strings have in common. You should treat upper and lower case letters as the same letter ('A,...