Target sum problem facing issue

#include
using namespace std;

void Search(int arr[],int n,int sum)
{
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
if(arr[i]+arr[j]==sum)
{
cout<<arr[i]<<" and "<<arr[j]<<endl;
}
}
}
}
int main()
{
int n;
cin>>n;
int arr[1000];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}

int sum;
cin>>sum;
Search(arr,n,sum);

}

test cases are failing

kindly share the link of code

hi @tarun1010
you have to Print each pair in increasing order.
and also start the loop of j from i+1

Modified Code
https://ide.codingblocks.com/s/653570

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.