From 728e5f31ad0ae25f81fcfe6ba86165742db95e79 Mon Sep 17 00:00:00 2001 From: Sagar Pasrija Date: Sat, 5 Oct 2019 14:11:22 +0530 Subject: [PATCH] Create bubblesort.cpp --- cpp/bubblesort.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cpp/bubblesort.cpp diff --git a/cpp/bubblesort.cpp b/cpp/bubblesort.cpp new file mode 100644 index 0000000..d3b03ba --- /dev/null +++ b/cpp/bubblesort.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; +void swapping(int *ptr1, int *ptr2){ + int temp=*ptr1; + *ptr1=*ptr2; + *ptr2=temp; +} +void bubble_sort(int arr[], int n){ + int i,j; + for(i=0;iarr[j+1]){ + swapping(&arr[j], &arr[j+1]); + } + } + } +} +void print_arr(int arr[], int n){ + for(int i=0;i>n; + int arr[n]; + cout<>arr[i]; + } + bubble_sort(arr, n); + cout<