Create a void function called display with 2 parameters: the array to be displayed and size and use a dynamic array of type int and complete the main program. CODE: #include using namespace std; void bubleSort(int *a, int n); void display(int *a, int n); int main() { // your declarations here... cout << "Enter number of elements to be sorted: "; //accept inputs... cout << "Enter the values ... \n"; bubleSort(num, size); } void bubleSort(int *a, int n) { int last = n - 1; cout << "\nBubble Sort..." << endl << endl; for (int i = 0; i < last; i++) { for (int j = last; j > i; j--) if (a[j - 1] > a[j]) swap(a[j], a[j - 1]); cout << "Pass " << i + 1 << "...." << endl; display(a, n); cout << endl; } } void display(int *a, int n) { }
Create a void function called display with 2 parameters: the array to be displayed and size and use a dynamic array of type int and complete the main program.
CODE:
#include <iostream>
using namespace std;
void bubleSort(int *a, int n);
void display(int *a, int n);
int main()
{
// your declarations here...
cout << "Enter number of elements to be sorted: ";
//accept inputs...
cout << "Enter the values ... \n";
bubleSort(num, size);
}
void bubleSort(int *a, int n)
{
int last = n - 1;
cout << "\nBubble Sort..." << endl << endl;
for (int i = 0; i < last; i++)
{
for (int j = last; j > i; j--)
if (a[j - 1] > a[j])
swap(a[j], a[j - 1]);
cout << "Pass " << i + 1 << "...." << endl;
display(a, n);
cout << endl;
}
}
void display(int *a, int n)
{
}
Step by step
Solved in 3 steps with 1 images