Created
May 12, 2024 13:02
-
-
Save jmichalenko/e56a4f7cce3eb20305a10d032c82271a to your computer and use it in GitHub Desktop.
bubble sort starter code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// complete the bubble_sort function | |
#include <cs50.h> | |
#include <stdio.h> | |
// function prototypes | |
void bubble_sort(int arr[], int size); | |
void print_array(int arr[], int size); | |
// size of array | |
#define SIZE 10 | |
int main(void) | |
{ | |
// initialize array | |
int arr[] = {1, 8, 4, 6, 0, 3, 5, 2, 7, 9}; | |
// sort array | |
bubble_sort(arr, SIZE); | |
// print out the array | |
print_array(arr, SIZE); | |
// done | |
return 0; | |
} | |
// Function to print an array | |
void print_array(int arr[], int size) | |
{ | |
for (int i = 0; i < size; i++) | |
{ | |
printf("%i ", arr[i]); | |
} | |
printf("\n"); | |
} | |
// bubble sort | |
void bubble_sort(int arr[], int size) | |
{ | |
// TODO | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment