From 6a0e338c825334db5f1359dd4ae644bf0d34fc12 Mon Sep 17 00:00:00 2001 From: abhishek5937 Date: Fri, 12 Oct 2018 13:13:54 +0530 Subject: [PATCH] Bubble sort in c++ --- BUBBLESO.CPP | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 BUBBLESO.CPP diff --git a/BUBBLESO.CPP b/BUBBLESO.CPP new file mode 100644 index 0000000..51d7cdb --- /dev/null +++ b/BUBBLESO.CPP @@ -0,0 +1,32 @@ +#include +#include +void bubbleSort(int ar[],int n) +{ + for(int i=0;iar[j+1]) + { + int temp=ar[j]; + ar[j]=ar[j+1]; + ar[j+1]=temp; + } +} +void main() +{ + clrscr(); + int arr[10],n,k,i,item; + cout<<"Enter size of array (max. 10 elements) : "; + cin>>n; + cout<<"Enter elements in array : "<>arr[i]; + } + bubbleSort(arr,n); + cout<<"Sorted array : "<