diff --git a/Sorting/Bubble Sort.cpp b/Sorting/Bubble Sort.cpp index c94a45efc..21402f334 100644 --- a/Sorting/Bubble Sort.cpp +++ b/Sorting/Bubble Sort.cpp @@ -6,9 +6,10 @@ using namespace std; int main() { int n; + short swap=0; cin >> n; int Array[n]; - cout<<"\nEnter any 6 Numbers for Unsorted Array : "; + cout<<"\nEnter any "<Array[j+1]) { + swap=1; int temp=Array[j]; Array[j]=Array[j+1]; Array[j+1]=temp; } } + if(swap == 0) + { + break; + } } //Output