Selection Sort problem

Please help me out here as the output is not correct
here is my code
#include
using namespace std;
void selection(int a[],int n)
{
for(int i=0;i<n-1;i++)
{
int min=a[i];
for(int j=i+1;j<n;j++)
{
if(a[j]<min)
{
int t;
t=a[j];
a[j]=min;
min=a[j];
}
}
}
for(int i=0;i<n;i++)
{
cout<<a[i]<<endl;
}
}
int main() {

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
selection(a,n);
return 0;

}

@Dhruv-Miglani-2090236747707980 hey please next time save your code on coding blocks ide i have corrected your code basically you have to select min value in each pass .i have made some modification you can refer this this.

Hey Dhruv,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.