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.
char* concatenation(char* arr[], int n){ int i, newSize = 1, j, k = 0; char* newArr; for(i = 0;i<n;i++){ newSize += strlen(arr[i]); } newArr = (char*)malloc(sizeof(newSize)); for(i = 0;i<n;i++){ for(j = 0;j<strlen(arr[i]);j++){ newArr[k++] = arr[i][j]; } } newArr[newSize-1] = '\0'; return newArr; }
Write a function that takes an array of C-strings as a parameter and the number of...
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 C++ function that takes a pointer to an array of integers as a parameter and return the number of prime integers in the array. Write main() program to test the function.
Write a method named avgLength which takes an array of Strings as an input parameter and returns a double. The method should calculate and return the average length of all the strings in the array (in java langauge)
Do the following: - Write and test a function that takes an array of doubles and returns the average of the values in the array - Write and test a function that takes an array of doubles and returns number of values in the array that are above the average of the values in the array - Write and test a function that takes an array of Strings and returns number of values in the array that start with an...
Write a python function alt which takes a list of strings myList as a parameter. alt then returns two strings s1 and s2 as a tuple (s1, s2). Here s1 is the concatenation of the strings in myList in even index positions, and s2 is the concatenation of the strings in myList in odd index positions. (List starts at index 0) For example, if myList = [‘My’, ‘kingdom’, ‘for’, ‘a’ , ‘horse’], then s1 = ‘Myforhorse’ and s2 = ‘kingdoma’.
Note that the main function that I have provided does use <string.h> as it constructs test strings to pass to your functions. However, your solutions for the 5 functions below may not use any of the built-in C string functions from the <string.h> library. Write a function called strcmp373. This function is passed two parameters, both of which are C strings. You should use array syntax when writing this function; that is, you may use [ ], but not *...
Please use C Programming, thanks! Write the prototype of a function that takes two strings as parameters (without using array notation) and returns the longer string.
Write a method markLength4 that takes an array of Strings as a parameter and that places a string of four asterisks "****" in front of every string of length 4.
Write a value-returning C++ function returns the average length of an array of strings. Name the function stringsAverageLength and use the following header: double stringsAverageLength(string array [], int n) { } where the parameter 'array' has 'n' strings and the return value is the average length of all of the strings in the array. For example, if the function is called like this: string cars[3] = { "Toyota", "Ford", "Tesla" }; cout << fixed << setprecision(2) << stringsAverageLength(cars, 3) <<...
a. Write a function arrayToMap that takes an array of strings and returns a std::map<int, string> such that the values in the map are the string values in the array of strings, and the keys in the map are the corresponding array indices of the string values. You may assume all necessary libraries have been included in your program and your solution must be syntactically correct in order to receive full credit. map<int, string> arrayToMap(string arr[], int arrSize) { b....