Selection sort code

even the simplest of code is not working today;)
#include
using namespace std;

int main()
{
int n;
cin>>n;

 int i,j,a[n],min;

 for(i=0;i<n;i++)
  cin>>n;

 for(i=0;i<n-1;i++)
 {  
      min=i;
    for(j=i+1;j<n;j++)
    {
         
        if(a[min]>a[j])
          min=j;
    }
       swap(a[min],a[i]);
 } 


 for(i=0;i<n;i++)
   cout<<a[i]<<endl;
  
  return 0;

}

@Asis hey please next time save your code on cb.lk/ide so that we can help you asap.
your code is not working because you’re taking input n in loop n but you should take input in array
change input loop
cin>>n;
to cin>>a[i];

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.