Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer all parts, thanks! Complete arrCopy.c (below) so that it outputs the following sample result in the same format. You must only insert code
Please answer all parts, thanks!
Complete arrCopy.c (below) so that it outputs the following sample result in the same format. You must only insert code in the segments labeled with //Your code here. Contents of all arrays must be accessed through pointers, so you must not use any array notation [ ] Use dynamic memory allocation (malloc) Your program must produce an identical output to that below, including spacing, formatting, wording, inputs, etc. Enter the size of array you wish to create: 5 Enter array element \#1: 1 Enter array element \#2: 2 Enter array element \#3: 3 Enter array element \#4: 4 Enter array element \#5: 5 Original array's contents: 120345 Contents of new array containing even elements from original: 24 Contents of new array containing odd elements from original: 135 Enter the size of array you wish to create: Original array's contents: empty Contents of new array containing even elements from original: empty Contents of new array containing odd elements from original: empty Enter the size of array you wish to create: 4 Enter array element \#1: 1 Enter array element \#2: 3 Enter array element \#3: 5 Enter array element \#4: 7 Original array's contents: 1307 Contents of new array containing even elements from original: empty Contents of new array containing odd elements from original: 1357 \#inc ludeh> \#includeh> int size; // Variable to record size of original array arr int evenCount =0, oddCount =0;/1 Variables to record sizes of new arrays arr_even and arr_odd int * *arr; // Dynamically allocated original array with \#elements = size int *arr_even; // Dynamically allocated array with \#elements = \#even elements in arr (evencount) int *arr_odd; // Dynamically allocated array with \#elements = \#odd elements in arr (oddCount) char str1 = "Original array's contents: "; char str2 = "Contents of new array containing even elements from original: "; char str 3= "Contents of new array containing odd elements from original: "; // DO NOT change the definition of the printarr function when it comes to I/ adding/removing/modifying the function parameters, or changing its return II type. void printArr(int *a, int size, char * prompt) \{ \} /I Your code here // DO NOT change the definition of the arrcopy function when it comes to I/ adding/removing/modifying the function parameters, or changing its return I/ type. void arrcopy( ) I/ Your code here \} int main( ) int i; printf("Enter the size of array you wish to create: "); scanf("\%d", \&size); I/ Dynamically allocate memory for arr (of appropriate size) I/ Your code here // Ask user to input content of arr and compute evencount and oddCount /I Your code here /I Dynamically allocate memory for arr_even and arr_odd (of appropriate size) I/ Your code hereStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started