From 42e557658203bd1bce82a29e3165b97b7f975247 Mon Sep 17 00:00:00 2001 From: Sejal Kothari <91632881+Sejzz@users.noreply.github.com> Date: Sun, 22 Oct 2023 19:21:33 +0530 Subject: [PATCH] Create bubble.cpp --- algorithms/bubble.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 algorithms/bubble.cpp diff --git a/algorithms/bubble.cpp b/algorithms/bubble.cpp new file mode 100644 index 00000000..bdd262c4 --- /dev/null +++ b/algorithms/bubble.cpp @@ -0,0 +1,33 @@ +#include +#include +using namespace std; + + +void bubblesort(int arr[], int n){ + for(int i = 0; iarr[j+1]){ + swap(arr[j],arr[j+1]); + } + } + } +} + +int main(){ + + + // int i, arr[8]; + int arr[] = {-2,3,4,-1,5,-12,6,1}; + + int n = sizeof(arr)/sizeof(int); + + cout<<"Sorted array: "<