From d1721e7d7b5d9b1d657daefa34068e00320e0489 Mon Sep 17 00:00:00 2001 From: Keshav Malik <33570148+kmalik31@users.noreply.github.com> Date: Mon, 7 Oct 2019 14:19:12 +0530 Subject: [PATCH] Create bubblesort.cpp Added BubbleSort.cpp --- bubbleSort.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bubbleSort.cpp 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