Related questions
Write a function/ program that produces the following:
int findDifference(const string a1[], int n1, const string a2[], int n2); Return the position of the first corresponding elements of a1 and a2 that are not equal. n1 is the number of interesting elements in a1, and n2 is the number of interesting elements in a2. If the arrays are equal up to the point where one or both runs out, return the smaller of n1 and n2.
Notwithstanding each function's behavior described below, all functions that return an int must return −1 if they are passed any bad arguments (e.g. a negative array size, or a position that would require looking at the contents of an element past the last element we're interested in). Unless otherwise noted, passing 0 to the function as the array size is not itself an error; it merely indicates the function should examine no elements of the array.
Here's an example:
string cast[5] = { "samwell", "jon", "margaery", "daenerys", "tyrion" }; string roles[4] = { "samwell", "jon", "sansa", "jaime" }; int k = findDifference(cast, 5, roles, 4); // returns 2 int m = findDifference(cast, 2, roles, 1); // returns 1
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Write a function that takes two string parameters and their common length. It fills out the second array with the capital form of the first parameter. Test your function in the main program.arrow_forwardWhich one of these functions will always return the highest number stored in the array passed to it? static int max(int[] a) int m = a[0]; for (int num : a) if (num> m) m = num; max - m; } static int max (int[] a) { int m = a[0]; for (int num: a) if (num> m) return num; return m; static int max (int[] a) int m = a[0]; for (int num : a) if (num> m) m - num; return num; static int max(int[] a) { int m; for (int num : a) if (num> m) m = num; return m; } static int max (int[] a) { int m = a[0]; for (int num : a) if (num> m) m = num; return m;arrow_forwardCreate a function using Java: Number of Rows = 3-6 Number of Columns = 3-6 Function Name: winInDiagonalFSParameters: board: 2D integer array, piece: integerReturn: booleanAssume board is valid 2D int array, piece is X==1/O==2.Look at all forward slash / diagonals in the board. If any forward slash / diagonals has at least 3consecutive entries with given type of piece (X/O) (3 in a row XXX, OOO), then return true,otherwise falsearrow_forward
- Write a function named "changeCase" that takes an array of characters terminating by NULL character (C-string) and a boolean flag of toUpper. If the toUpper flag is true, it will go through the array and convert all lowercase characters to uppercase. Otherwise, it will convert all uppercase to lowercase. For example, if the array is {'H', 'e', 'l', 'l', 'o', '0円'} and the flag is true, then the array will become {'H', 'E', 'L', 'L', 'O', '0円'}. And if the flag is false, the array will become{'h', 'e', 'l', 'l', 'o', '0円'}arrow_forwardWrite a function in C language that will take a 2D Array of size 3x3 from the user. Your Program should: 1. Prompt the user to enter 2D array of size 3x3. 2. Calculate the sum of all rows. 3. Calculate the sum of all columns 4. Return 1 if the sum of all rows is greater than sum of all columns, 0 otherwise. Your main program should print the result based on the returned values.arrow_forwardCreate a function named "onlyOdd".The function should accept a parameter named "numberArray".Use the higher order function filter() to create a new array that only containsthe odd numbers. Return the new array.// Use this array to test your function:const testingArray = [1, 2, 4, 17, 19, 20, 21];arrow_forward
- Must be written in the coral language. Complete the PrintArray function to iterate over each element in dataValues. Each iteration should put the element to output. Then, put "*" to output. Ex: If dataValue's elements are 2 4 7, then output is: 2*4*7*arrow_forwardmergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the parameters and returns an int[]. Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.arrow_forwardPrompt: In Python language, write a function that applies the logistic sigmoid function to all elements of a NumPy array. Code: import numpy as np import math import matplotlib.pyplot as plt import pandas as pd def sigmoid(inputArray): modifiedArray = np.zeros(len(inputArray)) #YOUR CODE HERE: return(modifiedArray) def test(): inputs = np.arange(-100, 100, 0.5) outputs = sigmoid(inputs) plt.figure(1) plt.plot(inputs) plt.title('Input') plt.xlabel('Index') plt.ylabel('Value') plt.show() plt.figure(2) plt.plot(outputs,'Black') plt.title('Output') plt.xlabel('Index') plt.ylabel('Value') plt.show() test()arrow_forward
- write in html and scriptarrow_forwardImagine that you are a biomedical engineer analyzing DNA sequences. You have numerical measurements from two different measurement sources, m1 and m2, both of which are arrays. Write a function named dna that takes these two arrays as inputs. It should return a character array string of nucleotides (represented by the letters A, C, G and T). For a given index, i, the nucleotide in the string is: - ‘A’ if m1(i) >= 0 and m2(i) >= 0 - ‘C’ if m1(i) < 0 and m2(i) >= 0 - ‘G’ if m1(i) >= 0 and m2(i) < 0 - ‘T’ if m1(i) < 0 and m2(i) < 0 code to call the function m1 = [-2 -3 2.5 0.3]; m2 = [1.1 2.1 -0.8 0.1]; sequecne = dna(m1,m2); function dna Please use MATLABarrow_forwardWrite a C function countEven() that takes an integer array and the number of elements in the array as parameters, finds and returns the number of even numbers in the array. Prototype: int countEven(int ar[], int n);arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY