63 036
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #73322 in C++ for Sani

Question #73322
Implement another function; pass the array (again using a pointer) to it. The function should then sort the array using the Bubble Sort algorithm. The function should use pointers for all computations (counter variables, traversal, swap).Give me code in c++
Expert's answer
#include <iostream>



using namespace std;



int sort(int* arr, int size)

{

int temp;



for (int i = 0; i < size - 1; i++)

{

for(int j = 0; j < size - i - 1; j++)

{

if(arr[j] > arr[j+1])

{

temp = arr[j];

arr[j] = arr[j+1];

arr[j+1] = temp;

}

}

}

}



int main()

{

int arr[10] = {6,8,25,9,65,3,57,12,4};

sort(arr, 10);



return 0;

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions