Saturday, November 15, 2025

BUBBLE SORT IN CPP

 #include <iostream>

 using namespace std;
 void SortArray(int a[],int n){
int temp;
for(int i=0;i<n;i++){
    for(int j=0;j<n-i-1;j++){
        if(a[j]>a[j+1]){
            temp=a[j];
            a[j]=a[j+1];
            a[j+1]=temp;
        }
    }
}
 }
 int main() {
 //Write your C++ code here
 int A[]={1,34,78,54,75,12};
 int n=6;
 SortArray(A,n);
 for(int i=0;i<6;i++){
    cout<<A[i]<<endl;
 }
 return 0;
 }

No comments:

Post a Comment

MergeSort

  #include < iostream >   using namespace std ;   void merge ( vector < int >& n , int low , int mid , int high ){   ...