Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in c++ ROGRAMMING. Write the code for the specified rogram. Use proper style and

ID: 3738684 • Letter: I

Question

in c++

ROGRAMMING. Write the code for the specified rogram. Use proper style and naming. You may omit omments, inclusions, and namespace specifiers. (10 pts) 22) 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

Explanation / Answer

int* arrayFunction(int inArray[], int nSize)

{

int* newArray = new int[nSize*2];

for(int itr = 0; itr < nSize*2; itr++)

{

if(itr < nSize)

newArray[itr] = inArray[itr]; // storing sme value as in input array

else

newArray[itr] = 0; // initializing rest of the element with 0

}

return newArray;

}