Numerical Sort Recompiles .c

RJM Programming - November, 2024

#include <stdio.h>
#include <stdbool.h>

/* Thanks to https://www.w3schools.com/dsa/trydsa.php?filename=demo_bubblesort */
int main() {
int my_array[] = {
};
int n = sizeof(my_array) / sizeof(my_array[0]);

for (int i = 0; i < n-1; i++) {
bool swapped = false;
for (int j = 0; j < n-i-1; j++) {
if (my_array[j] > my_array[j+1]) {
int temp = my_array[j];
my_array[j] = my_array[j+1];
my_array[j+1] = temp;
swapped = true;
}
}
if (!swapped) {
break;
}
}

printf("
Sorted array: ");
for (int i = 0; i < n; i++) {
printf("%d ", my_array[i]);
}
printf("\n");

return 0;
}

//C