Program not running!

#include
#include<bits/stdc++.h>
using namespace std;
int main(){

int n , a[n], target;
cin>>n;

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

sort(a, a+n);

cin>>target;  

for(int i =0 ; i<n-1 ; i++)
 {  
     for(int j = i+1; j<n ; j++)
      {   
          if((a[i]+a[j])==target)
          cout<<a[i]<<" and "<<a[j]<<endl;
      }
      
 }

why it isn’t working?

here a[n] declaring array in this way is incorrect
because before taking n you can’t use it as size of array

Modified Code

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.