please check it and run the code
Why there is no output?
Check your loop section. You are not updating left and right pointer when there is a match.
It must be something like this:
Something like this:
while(l<r){
cs= a[l]+a[r];
if(cs>target){
r--;
}
else if(cs==target){
cout<<a[l]<<" and "<<a[r]<<endl;
l++;
r--;
}
else l++;
}