Question: Implement the sort procedure from Assignment 18 as a void function. Pass the address of the first array element to the function along with the

Implement the sort procedure from Assignment 18 as a void function. Pass the address of the first array element to the function along with the number of elements in the array. Use pointers in your function to reference the array elements. The sort function should do nothing but sort the elements of the array. DO NOT pass the entire array as an argument to the function.

As in Assignment 18, print out the array before and after sorting. Use the same test data.

All output should be in main(), not in the function.

REFERENCE ONLY ASSIGNMENT 18:

Consider the following sort procedure written in pseudo code:

Exchange Sort of Array X[]

For I = 0 to (number of array elements - 2), increment by 1 For J = (I + 1) to (number of array elements - 1), increment by

If X[I] is greater than X[J] then

temp = X[I]

X[I] = X[J]

X[J] = temp

Next J

Next I

Implement the sort procedure in main() without using pointers. Declare the array as follows using the test data shown:

int x[] = { 28, 87, -3, 45, 19 }; Use a for loop to print out the array before sorting and again after sorting. Thereshould be no output within the sort procedure.

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!