Question
Study and complete arrCopy.c so it prints out the following sample result in the same format. You must only insert code in the segments where
Study and complete arrCopy.c so it prints out the following sample result in the same format. You must only insert code in the segments where //Your code here is labeled. Contents of all arrays must be accessed through pointers, so you must not use any array notation [ ] in the code. Hint: Use dynamic memory allocations! Sample result (input is in italic and bold): Enter size of array: 5 Enter array content #1: 1 Enter array content #2: 3 Enter array content #3: 5 Enter array content #4: 7 Enter array content #5: 9 printArr: 1 3 5 7 9 printArr: 1 3 5 7 9
#include
void printArr(int *a, int size){ //Your code here }
int* arrCopy(int *a, int size){ //Your code here }
int main(){ int n; int *arr; int *arr_copy; int i; printf("Enter size of array: "); scanf("%d",&n);
//Dynamically create an int array of n items //Your code here
//Ask user to input content of array //Your code here /*************** YOU MUST NOT MAKE CHANGES BEYOND THIS LINE! ***********/ //Print original array printArr(arr, n);
//Copy array arr_copy = arrCopy(arr, n);
//Print new array printArr(arr_copy, n);
return 0; }
Step 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