From e765eb7acb121031dcacd43e9e663ce09d92a3bb Mon Sep 17 00:00:00 2001 From: sunidhib2002 Date: Tue, 25 May 2021 23:35:35 +0530 Subject: [PATCH] Added Bubble sort code --- BubbleSort.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 BubbleSort.cpp diff --git a/BubbleSort.cpp b/BubbleSort.cpp new file mode 100644 index 0000000..37404b3 --- /dev/null +++ b/BubbleSort.cpp @@ -0,0 +1,28 @@ +#include + +using namespace std; + +int main() +{ + int arr[10]={10,30,20,50,40,60,90,70,100,80}; + + for(int i=0;i<8;i++) + { + for(int j=0;j<9;j++) + { + if(arr[j]>arr[j+1]) + { + int temp; + temp=arr[j]; + arr[j]=arr[j+1]; + arr[j+1]=temp; + } + } + } + + for(int i=0;i<10;i++) + { + cout<