Create a function that takes in an integer array called “input” and size. The function should return a pointer to a dynamically created array the has two locations. The first is the minimum number in the input array and the second is the maximum number in input. Demonstrate your work by calling this function in main. The program should be c++
#include <iostream>
using namespace std;
int* getMinMax(int arr[], int size){
int* res = new int[2];
if(size > 0){
int min = arr[0], max = arr[0];
for(int i = 1;i<size;i++){
if(min > arr[i]){
min = arr[i];
}
if(max < arr[i]){
max = arr[i];
}
}
res[0] = min;
res[1] = max;
}
return res;
}
int main(){
int input[] = {3,4,2,5,1,2};
int size = 6;
int* res = getMinMax(input,size);
cout<<"Min = "<<res[0]<<endl;
cout<<"Max = "<<res[1]<<endl;
return 0;
}


Create a function that takes in an integer array called “input” and size. The function should...
In C: Write a function "MinMax" that takes as an argument an integer array, an integer for the size of the array, and two integer pointers. The function should print nothing and return nothing but change the value of the first pointer to the minimum value in the array and change the value in the second pointer to the max value in the array.
(C++)Write a function that accepts an int array and the array’s size as arguments.The function should create a new array that is twice the size of the argument array.The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0.The function should return a pointer to the new array.Demonstrate the function by using it in a main program that reads an integer N (that is not more...
9.10: Reverse Array Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function by using it in the main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named...
Create a function that takes two parameters : pointer to the array and the size of the array. Print out the array's values and their memory addresses inside the function. Then create another function that takes two parameters : pointer to the array. Inside the function, multiply each of the array's values by two ad print the modified values out in the main function. With C programming language
Write a program that dynamically allocates an integer array of size of 20 to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to • a function that calculates the average score, the minimal score, and the maximal score in the array, and returns these scores to the main function (hint: use pass by reference, I gave an example in the class) • a function that searches a specific number. The...
Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...
Class Average Create a program that dynamically creates an array whose size depends on the user's preference. Pass the array to a calculate_avg function that is responsible for computing the average GPA of the given array. Use pointer arithmetic throughout your program. calculate_avg Create a function called calculate_avg that calculates the average of a double array and returns that average. calculate_avg() will have two parameters: a double* referring to the array an int that contains the size of the given...
C++ Write a function called reverseArray(char[] , int) that accepts in an array of chars and the size of the array.as parameters. The function should then create a new array that is the same size as the original array. The function should copy the elements from the first array into the second array in reverse order. So if the initial array is {'a' , 'b', 'c'} then the new array will be {'c', 'b', 'a'} Then in your main(), create...
-Create a function output() in C that takes the pointer to the array and its size and prints the arrays' contests. (malloc format) (function prototype : void output(int *arrayPtr, int size); -Create a function check() in C that takes the pointer to the array and a number and checks if the number is in the array. If the number is in the array, returns the index of the element of the array holding the number. Otherwise, returns -1.
A function that takes three parameters: an int array, an int n that is the size of the array and an int pointer max that is to assign the maximum value in the array. The function will find and return the index of the first occurrence of the maximum value in the array and assign the maximum value to the pointer. For example, in the array {1, 2, 6, 5, 6, 4, 3, 6, 4}, the maximum value is 6...