From 105a0103dd359b2cfd6293515d29c9222e52e952 Mon Sep 17 00:00:00 2001 From: Virendragurjar067 <115646146+Virendragurjar067@users.noreply.github.com> Date: Wed, 12 Oct 2022 20:24:04 +0530 Subject: [PATCH] Bubble sort program added --- bubble_sort.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bubble_sort.cpp diff --git a/bubble_sort.cpp b/bubble_sort.cpp new file mode 100644 index 0000000..ff5a2d5 --- /dev/null +++ b/bubble_sort.cpp @@ -0,0 +1,30 @@ +#include +using namespace std; +int main() +{ + int n, i, arr[50], j, temp; + cout<<"Enter the Size (max. 50): "; + cin>>n; + cout<<"Enter "<>arr[i]; + cout<<"\nSorting the Array using Bubble Sort Technique..\n"; + for(i=0; i<(n-1); i++) + { + for(j=0; j<(n-i-1); j++) + { + if(arr[j]>arr[j+1]) + { + temp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = temp; + } + } + } + cout<<"\nArray Sorted Successfully!\n"; + cout<<"\nThe New Array is: \n"; + for(i=0; i