Regarding selection sort

#include

using namespace std;
void selection_sort(int*, int);

int main(){
int n;
cin>>n;
int a[1000]={0};
for(int i=0; i<n; i++){
cin>>a[i];
}

selection_sort(a,n);
for(int i=0; i<n;i++){
    cout<<a[i]<<", ";
}
return 0;

}

void selection_sort(int a[], int n){
for(int i=0; i<n-1;i++){

    //find the smallest index element index in the unsorted portion
    int min_index=i;
    for(int j=0; j<=n-1;j++){
        if(a[j]<a[min_index]){
            min_index=j;
        }
    }

    //after this loop we can do a swap finally

    swap(a[i], a[min_index]);
}

}

//its not gives the sorted element, i am using codeblocks ide. please check.

Please save your code on ide.codingblocks.com and then share its link.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.