/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
int bubblesort( int array[], int n){
int i,j,temp, switched = 1;
for(i=0;i<n-1;i++){
//outer loops controls the number of passes
switched= 0;//no interchange have been made
for(j=0; j<n-i-1; j++){
//inner loop controls the function in each pass
if( array[j] > array[j+1]){
switched= 1;
temp= array[j];
array[j]= array[j+1];
array[j+1]=temp;
}
}
}
} //bubble end
int main()
{
int array[5] = {23, 54, 21, 9, 10};
bubblesort(array, 5);
for(int i=0; i<5; i++){
printf("%d \t", array[i]);
}
return 0;
}