Target sum pair(one test case is not passing)

#include
using namespace std;
int main()
{
int n,sum;
int i,j;
int arr[1000];
cin>>n;
for(i=0;i<n;i++){
cin>>arr[i];
}
cin>>sum;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(arr[i]+arr[j]==sum&&i!=j){
cout<<arr[i]<<" and "<<arr[j]<<endl;
}
}
}
return 0;
}

@kundankumarsports2
hello kundan,
first print smaller number than biggr number

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.