Question: C++ help please and thank you. this is my assignment. Implement the sort procedure from Assignment 18 as a void function. Pass the address of
C++ help please and thank you. this is my assignment.
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
this is my program from Assignment 18
//PROG18.cpp Sort an array #include using namespace std;
void ExchangeSort (int array[5]) { int i,j,temp;
for (i=0;i<4;i++) { for (j= (i+1);j<5;j++) { if (array[i]>array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } } } int main() { int x[] = {28,87,-3,45,19}; int i;
cout<< "Array elements before sorting :"; for (i=0;i<5;i++) { cout< } ExchangeSort(x); cout<<" array elements after sorting :"; for (i=0;i<5;i++) { cout< } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
