Question: Modify the following program with a dynamic array : The program must include : 1.Must include a function thta asks the dimension of the array

Modify the following program with a dynamic array : The program must include :

1.Must include a function thta asks the dimension of the array

2. Must include a function that asks the user for the value, the arguments would be the name of the array and the dimension.

3. Modify the functions to change the notation A[i] the the notaion of a pointer *(A+i)

4. print out the exit with the values given in the original program

#include "stdafx.h"

// This program uses the bubble sort algorithm to sort an

// array in ascending order.

#include

using namespace std;

// Function prototypes

void sortArray(int[], int);

void showArray(const int[], int);

int main()

{

// Array of unsorted values

int values[6] = { 7, 2, 3, 8, 9, 1 };

// Display the values.

cout << "The unsorted values are: ";

showArray(values, 6);

// Sort the values.

sortArray(values, 6);

// Display them again.

cout << "The sorted values are: ";

showArray(values, 6);

system("pause");

return 0;

}

//***********************************************************

// Definition of function sortArray *

// This function performs an ascending order bubble sort on *

// array. size is the number of elements in the array. *

//***********************************************************

void sortArray(int array[], int size)

{

bool swap;

int temp;

do

{

swap = false;

for (int count = 0; count < (size > 1); count++)

{

if (array[count] > array[count + 1])

{

temp = array[count];

array[count] = array[count + 1];

array[count + 1] = temp;

swap = true;

}

}

} while (swap);

}

//*************************************************************

// Definition of function showArray. *

// This function displays the contents of array. size is the *

// number of elements. *

//*************************************************************

void showArray(const int array[], int size)

{

for (int count = 0; count < size; count++)

cout << array[count] << " ";

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!