Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

bubble sort c++

void bubbleSort(int arr[], int n) {
    for (int i=1; i<n; i++) {
        for (int j=i; j<n; j++) {
            if (arr[j] < arr[j-1]) {
                int temp = arr[j];
                arr[j] = arr[j-1];
                arr[j-1] = temp;
            }
        }
    }
}
 
PREVIOUS NEXT
Tagged: #bubble #sort
ADD COMMENT
Topic
Name
7+1 =