The program should have an array of integers. It will have a function that has two parameters, the integer array and the array’s size. This function will create a new array that is twice the size of the arguments 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 must return a pointer to the new array. The program will then display the contents of the new array. Program must have the following functions Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it Purchase the answer to view it

In this assignment, we are required to create a program that involves an array of integers and a function that performs certain operations on this array. The goal is to create a new array that is twice the size of the original array and copy the contents of the argument array into the new array. Additionally, the unused elements of the new array should be initialized with 0. Finally, we need to display the contents of the new array.

To fulfill these requirements, we will start by defining our program with an array of integers. This array will serve as the argument array for our function. The size of this array will also be specified.

Next, we will write a function that takes two parameters: the integer array and the size of the array. This function will create a new array that is twice the size of the argument array. To achieve this, we will dynamically allocate memory for the new array using the “malloc” function. The size of the new array will be calculated by multiplying the size of the argument array by 2.

After successfully allocating memory for the new array, we will copy the contents of the argument array into the new array. This can be done using a loop that iterates over each element of the argument array and assigns the same value to the corresponding element in the new array.

Next, we will initialize the unused elements of the new array with 0. Since the new array is twice the size of the argument array, we need to initialize the remaining elements (the elements beyond the size of the argument array) with 0. Again, this can be achieved using a loop that starts from the index after the last element of the argument array and assigns 0 to each element until the end of the new array.

Finally, the function should return a pointer to the new array, which will be used to display the contents of the new array in the main program.

In the main program, we will call this function, passing the argument array and its size as parameters. We will store the returned pointer in a variable, and then iterate over each element of the new array using a loop. During each iteration, we will print the value of the current element.

To summarize, the program will have an array of integers and a function that creates a new array twice the size of the argument array, copies the contents of the argument array into the new array, initializes the unused elements with 0, and returns a pointer to the new array. The main program will display the contents of the new array.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer