Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

Students also viewed these Databases questions

Question

1.what is the significance of Taxonomy ?

Answered: 1 week ago

Question

What are the advantages and disadvantages of leasing ?

Answered: 1 week ago

Question

Name is needed for identifying organisms ?

Answered: 1 week ago