Test case 4 not working

i dont know why test case 4 is failing output of testcase 4 is same as my output.

@shakul hey shakul copy your code on ide and then share it here so that I can help you asap.

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int a[n]={0};
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int target = 0;
cin>>target;
sort(a,a+n-1);
int *l=&a[0];
int *r=&a[n-1];
while(*l<*r)
{
if(*l+*r==target)
{
cout<<*l<<" and "<<*r;
r = r - 1;
l = l + 1;
}
else if(*l+*r>target)
{ r = r -1;}
else if(*l+*r<target)
{
l = l + 1;
}
else
{}
cout<<endl;
}
return 0;
}