Selection sort code

why my code is not sorting array
#include <bits/stdc++.h>
using namespace std;
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void selection_sort(int a[], int n){
for(int i=0;i<n-1;i++){
int min_indx=i;
for(j=i;j<=n-1;j++){
if(a[j]<a[min_indx]){
min_indx=j;
}
}
}

swap(a[i],a[min_indx]);

}

int main()
{
int i,n,j;
int a[1000];
cout<<“enter size of array”<<endl;
cin>>n;
cout<<“enter the elements of array”<<endl;
for(i=0;i<n;i++){
cin>>a[i];
}

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

return 0;

}

@adarshsingh2k put swap() inside for loop

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.