Bubble Sort Program in C
Bubble Sort Program in C
http://www.tutorialspoint.com/data_structures_algorithms/bubble_sort_program_in_c.htm
Copyright © tutorialspoint.com
Implementation in C
#include <stdio.h>
#include <stdbool.h>
#define MAX 10
void display(){
int i;
printf("[");
printf("]\n");
}
void bubbleSort() {
int temp;
int i,j;
swapped = true;
printf(" => swapped [%d, %d]\n",list[j],list[j+1]);
}else {
printf(" => not swapped\n");
}
main(){
printf("Input Array: ");
display();
printf("\n");
bubbleSort();
printf("\nOutput Array: ");
display();
}
If we compile and run the above program then it should produce following result −
Output
Input Array: [1 8 4 6 0 3 5 2 7 9 ]
Output Array: [0 1 2 3 4 5 6 7 8 9 ]