Menu

(Solved) : Exercise 1 Number Matches Write Function Named Numberof Matches Compares Initial Parts Two Q33025718 . . .

C++
Exercise #1: Number of Matches Write a function named number_of matches that compares the initial parts of two character arrays to see how many pairs of cells match before a difference occurs. For example, if the arrays are: 0 1 2 3 4 5 0 1 23 4 he a v e n and he a v y then the function should return the value 4 because only the first four pairs of cells in the arrays match (cell 0 matches cell O, cell 1 matches cell 1, cell 2, and cell 3). Each of the character arrays will end with the NUL terminator denoted by 0.The pairwise cell comparisons should not go beyond the end of either array. If the two arrays are identical all the way to their terminating NUL characters, the main program should tell that, and return the number of non-NUL characters. The function should take only two parameters, namely the two-character arrays to be compared. Sample input/output: Enter the first string: heaven Enter the secong string: heavy The number of matching characters between the two strings is: 4 Enter the first string: hello Enter the secong string: hello The two strings are equal and the number of non-null characters is: 5Exercise #1: Number of Matches Write a function named “number_of matches” that compares the initial parts of two character arrays to see how many pairs of cells match before a difference occurs. For example, if the arrays are: 0 1 2 3 4 5 0 1 23 4 he a v e n and he a v y then the function should return the value 4 because only the first four pairs of cells in the arrays match (cell 0 matches cell O, cell 1 matches cell 1, cell 2, and cell 3). Each of the character arrays will end with the NUL terminator denoted by 0′.The pairwise cell comparisons should not go beyond the end of either array. If the two arrays are identical all the way to their terminating NUL characters, the main program should tell that, and return the number of non-NUL characters. The function should take only two parameters, namely the two-character arrays to be compared. Sample input/output: Enter the first string: heaven Enter the secong string: heavy The number of matching characters between the two strings is: 4 Enter the first string: hello Enter the secong string: hello The two strings are equal and the number of non-null characters is: 5 Show transcribed image text

Expert Answer


Answer to Exercise 1 Number Matches Write Function Named Numberof Matches Compares Initial Parts Two Q33025718 . . .

OR