Target sum triplet

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
int arr[1000];
for(int i=0;i<n;i++){
cin>>arr[i];
}
sort(arr,arr+n);
int s;
cin>>s;
for(int i=0;i<n;i++){
int l=i+1;
int r=n-1;
int x=arr[i];
while(l<r){
if(x+arr[l]+arr[r]==s){
cout<<x<<", “<<arr[l]<<” and "<<arr[r]<<endl;
l++;
r–;
}
else if(x+arr[i]+arr[r]<s){
l++;
}
if(x+arr[i]+arr[r]>s){
r–;
}
}
}
return 0;
}

sir this code is not giving output.
tell me my mistake where i am wrong.

@piyush_sharma let me check your code.

@piyush_sharma hey I have corrected your code some small mistakes were there ,please check and dry run it:

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.