Arrays target sum pairs

what is the mistake i did here.
#include
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int target;
cin>>target;
for(int i=0;i<n;i++){
a[i] += a[i+1];
if(a[i]==target){
cout<<a[i] <<“and”<< a[i+1]<<endl;
a[i+1]++;
}
}

return 0;

}

#include using namespace std; int main(){ int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } int target; cin>>target; for(int i=0;i<n;i++){ a[i] += a[i+1]; if(a[i]==target){ cout<<a[i] <<“and”<< a[i+1]<<endl; a[i+1]++; } } return 0; }

The basic approach you need to follow is tht, you will take two nested loops, and then check if the sum is equal to target or not, if it is equal to target, you need to print the pairs,
for(int i=0;i<N;i++)
{
for(int j=i+1;j<N;j++)
{
if(ar[i]+ar[j]==target
cout<<…
}
}

only 2 test cases are correct. what is the mistake

Pls send your code … I will check it …

Since, you arent replying anything, I am marking this doubt as resolved… You can reopen it if u still face any issues…