From fac897898472058bd7044de9893c3ae2737c003b Mon Sep 17 00:00:00 2001 From: navdeepk037 <97962577+navdeepk037@users.noreply.github.com> Date: Tue, 11 Oct 2022 14:22:38 +0530 Subject: [PATCH] created the bubble sort created the bubble sort using cpp --- Algoritms/bubble_sort.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Algoritms/bubble_sort.cpp diff --git a/Algoritms/bubble_sort.cpp b/Algoritms/bubble_sort.cpp new file mode 100644 index 00000000..463b894e --- /dev/null +++ b/Algoritms/bubble_sort.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; +void printArr(int arr[], int n) +{ + for (int i = 0; i < n; i++) cout< arr[j+1]) + { + swap(arr[j], arr[j+1]); + swapped = true; + } + + } + if (swapped == false) break; + } +} +int main() +{ + int arr[6] = {10, 12, 45, 1, 23, 90}; + sortBubble(arr, 6); + printArr(arr, 6); +}