Question: Write a code which will swap two 1 - D arrays. In the main function, you will declare the two arrays ( x and y

Write a code which will swap two 1-D arrays.
In the "main" function, you will declare the two arrays (x and y in the figure below) and pass pointers to the arrays to a function called "swap1DArrays".
The function "swap1DArrays" will traverse the input arrays and swap the entries. This function should in turn call a function named "swapNumbers", which will swap the ith elements of the two input arrays. Therefore, the function "swap1 DArrays" will need to pass pointers to the ith elements of the two input arrays to the function "swapNumbers".
main
x= input array 1
y= input array 2
swap1DArrays
receives pointers to x and y
swapNumbers
receives pointers
to x[i] and y[i]
After the arrays have been swapped, you will need to add printf statements in "main" to print the original arrays and the swapped arrays. You can print out the arrays on the screen or write those to a file. If you decide to write the original and swapped arrays to a file, you will receive a
 Write a code which will swap two 1-D arrays. In the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!