| 1 | #include"bits/stdc++.h" //to include all the header files |
| 2 | using namespace std; |
| 3 | void bubble_sort(int arr[],int n) |
| 4 | { |
| 5 | for (int i = 0; i < n; i++) |
| 6 | { |
| 7 | for (int j = 0; j < n-1-i;j++) |
| 8 | { |
| 9 | if(arr[j]>arr[j+1]) |
| 10 | swap(arr[j],arr[j+1]);//using inbuilt swap function |
| 11 | } |
| 12 | } |
| 13 | } |
| 14 | int main(){ |
| 15 | int arr[]={2,4,2,77,43,74,354,63,62,6222}; |
| 16 | int n=sizeof(arr)/sizeof(int); |