diff --git a/bubbleSort.cpp b/bubbleSort.cpp new file mode 100644 index 0000000..14f6470 --- /dev/null +++ b/bubbleSort.cpp @@ -0,0 +1,31 @@ +#include + +using namespace std; +void swap(int &a,int &b) +{ + int temp; + temp=a; + a=b; + b=temp; +} +void bubbleSort(int ar[],int n) +{ + for(int i=0;iar[j+1]) + { + swap(ar[j],ar[j+1]); + } + } + } +} +int main() +{ + int ar[] = {10,4,21,3,2,5,9,19}; + int n=8; + bubbleSort(ar,n); + for(int i=0;i