From dcbfc6bb43df1d5c37ef9f3cfc3c209bb650022e Mon Sep 17 00:00:00 2001 From: sbis04 <43280874+sbis04@users.noreply.github.com> Date: Sun, 28 Oct 2018 23:17:27 +0530 Subject: [PATCH] bubble --- bubble_sort.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 bubble_sort.cpp diff --git a/bubble_sort.cpp b/bubble_sort.cpp new file mode 100644 index 0000000..61800c9 --- /dev/null +++ b/bubble_sort.cpp @@ -0,0 +1,46 @@ +#include +using namespace std; + +void b_sort(int n, int a[]); + +int main() +{ + int a[100], n; + + cout << "Enter the number of elements to be inserted: "; + cin >> n; + + cout << "Enter the elements: \n"; + for(int i=0; i> a[i]; + } + + b_sort(n, a); + + cout << "SORTED ARRAY: \n"; + for(int i=0; i a[j+1]) + { + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +}