All test case are not working

https://online.codingblocks.com/player/38289/content/18718/4812

code----->
#include
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int target;
cin>>target;

for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++)
 if((arr[i]+arr[j])==target)cout<<arr[i]<< " and " <<arr[j]<<endl;
    
}

return 0;

}

@ashish25patidar hey ashish this is because of sorted order sort the array before performing the operation

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.