From 76373bcb774bf9ece3189f2efa2ae41247d404b2 Mon Sep 17 00:00:00 2001 From: Uma-12345 <72243422+Uma-12345@users.noreply.github.com> Date: Fri, 16 Oct 2020 02:29:31 -0700 Subject: [PATCH] Create bublesort.c --- bublesort.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bublesort.c diff --git a/bublesort.c b/bublesort.c new file mode 100644 index 0000000..7806c83 --- /dev/null +++ b/bublesort.c @@ -0,0 +1,23 @@ +void swap(float* p1, float*p2){ + float temp=*p1; + *p1=*p2; *p2=temp; +} + +void bsort(float data[], int size){ + int i,swapping; + do { + swapping=0; + for(i=0;idata[i+1]) { + swap(&data[i],&data[i+1]); + swapping=1; + } + }while(swapping); +} + +void main(void){ + float d[]={12,34,56,78,43,23,5,7,9,32,23,56}; + int i; + bsort(d,12); + for(i=0;i<12;i++)printf("\n%f",d[i]); +}