Question: 5. Copy one array to another (20 marks) Write a C program that takes a hardcoded array of integers and copy the elements of
5. Copy one array to another (20 marks) Write a C program that takes a hardcoded array of integers and copy the elements of this hardcoded array into another array using pointers and use pointer notation to iterate through the elements. Displays the copied array as the output. You are required to implement the function copyArray and call that function from the main method. Note: Test your function by calling it in main with different input arrays. Arrays can be hardcoded. Implementation Details: /* */ Function: CopyArray Copy source array to destination array. Parameters: srcArray: Pointer to a source array destArray: Pointer to a destination array lenArray: Length of the source array Returns: void void copyArray(int *srcArray, int *destArray, int lenArray); This function copyArray takes an integer array as input (Source Array) and copy source array to Destination Array. Sample Input: int srcArray[] = {15, 56, 34, 78, 23}; int lenArray = sizeof(srcArray) / sizeof(srcArray[0]); int destArray[lenArray]; copyArray(srcArray, destArray, lenArray); Result: Destination Array: 15, 56, 34, 78, 23 (Make sure you print the commas also)
Step by Step Solution
3.43 Rating (150 Votes )
There are 3 Steps involved in it
SGDB mainc 1 include L234567 2 3 89101034560 12 17 18 19 void copy Arrayint srcA... View full answer
Get step-by-step solutions from verified subject matter experts
