Program work but having problem with code that will prints the array at
each step of the algorithm.
#include <iostream>
using namespace std;
void bubbleSortArray(int [], int);
void displayArray(int[], int);
const int SIZE = 8;
int main()
{
int values[SIZE] = {20,0,45,-3,-78,1,-1,9};
cout << "The values before the bubble sort is performed are:" << endl;
displayArray(values,SIZE);
bubbleSortArray(values,SIZE);
cout << "The values after the bubble sort is performed are:" << endl;
displayArray(values,SIZE);
system ("pause");return 0;
}
void displayArray(int array[], int elems)
{
for (int count = 0; count < elems; count++)
cout << array[count] << " " << endl;
}
void bubbleSortArray(int array[], int elems)
{
bool swap;
int temp;
int bottom = elems - 1;
use [ code ] [ / code ] next time without spaces, for readability.
also why would you bottom--; ? you're using it to remeber the amount of elements the array stores.