Here is a program that demostrates a bubble sort:

#include <iostream> using namespace std; void printArray(int *array, int length); void bubbleSort(int *array, int length); int main() { int array[] = {9,6,5,23,2,6,2,7,1,8}; bubbleSort(array, 10); printArray(array, 10); } void printArray(int *array, int length) { int i = 0; for(i =0; i < length; i++) cout << array[i] << endl; } void bubbleSort(int *array, int length) { int i, j; for(i = 0; i < length; i++) { for(j = 0; j < i; j++) { if(array[i] > array[j]) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } } } }