Question: Sorry Array with Pointers Read this explanation on bubble sorting https://goo.gl/PpRFM7 Then write a bubble sort to sort the following array from highest to smallest

Sorry Array with Pointers

Read this explanation on bubble sorting

https://goo.gl/PpRFM7

Then write a bubble sort to sort the following array from highest to smallest

int x[5] = {4,57,10,11,62};

using the pointers p1, p2 to do the sorting

int *p1 = x;

int *p2 = x+1;

The output should look like

Original: 4 57 10 11 62

Sorted: 62 57 11 10 4

Starter Code

#include

using namespace std;

int main() {

int x[5] = {4,57,10,11,62};

int *p1 = x;

int *p2 = x+1;

int temp;

bool check;

cout << "Original: ";

for (int i=0; i < 5; i++)

cout << *(x+i) << " ";

cout << endl;

do

{

// your code here

}while (check);

cout << "Sorted: ";

for (int i=0; i < 5; i++)

cout << *(x+i) << " ";

cout << endl;

}

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!