Why my selection sort is not passing for every case

#include<bits/stdc++.h>
using namespace std;
void swapa(int *a,int *b){
int temp=*a;
*a=*b;
*b=temp;
}
void selectionsort(int arr[],int n){
int mini;
for(int i=0;i<n-1;i++){
mini=i;
for(int j=i+1;j<n;j++)
if(arr[j]<arr[mini])
swapa(&arr[mini],&arr[i]);
}

for(int i=0;i<n;i++)cout<<arr[i]<<" ";

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

selectionsort(a, n);
return 0;
}

Hello @argus your code is not even producing the correct result for sample test case :
please dry run that.

#include<bits/stdc++.h>

using namespace std;

void swapa(int *a,int *b){

int temp=*a;

*a=*b;

*b=temp;

}

void selectionsort(int arr[],int n){

int mini;

for(int i=0;i<n-1;i++){

mini=i;

for(int j=i+1;j<n;j++)

if(arr[j]<arr[mini])

{

mini=j;

}

swap(arr[i],arr[mini]);

}

for(int i=0;i<n;i++)cout<<arr[i]<<endl;

}

int main(){

int n;

cin>>n;

int a[n];

for(int i=0;i<n;i++)

cin>>a[i];//cout<<a[i];

selectionsort(a, n);

return 0;

}
check this code:
Happy Learning!!

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.