Target sum pair

void sum_pairs(int a[1000], int n, int target) {
int sum =0;
for(int i=0; i<n; i++) {
for(int j=i+1; j<n; j++) {
sum = a[i]+a[j];
if(sum==target) {
cout<<a[i]<<“and”<<a[j]<<endl;
}
}
}
return;
}
int main() {
int n,target;
cin>>n;
int a[1000] = {0};
for(int i=0; i<n; i++) {
cin>>a[i];
}
cin>>target;
sum_pairs(a,n,target);
return 0;
}

My code is giving the right output but not passing any test case.

you are failing testcases because you have to Print each pair in increasing order as mention in question

like this

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.

@guptariya0207
i hope your doubt is resolved
if yes then plz give your feedback https://online.codingblocks.com/feedback/d/75511
else feel free to ask