Array target sum pair hint

what is wrong in the below code ??

#include
using namespace std;

// Returns number of pairs in arr[0…n-1]
// with sum equal to ‘sum’
int printPairs(int arr[], int n, int target)
{
int count = 0; // Initialize result

// Consider all possible pairs and check 
// their sums 
for (int i = 0; i < n; i++) 
    for (int j = i + 1; j < n; j++) 
        if (arr[i] + arr[j] == target) 
            cout << "(" << arr[i] << ", "
                 << arr[j] << ")" << endl; 

}

// Driver function to test the above function
int main()
{

int n;
cin>>n;
int arr[n];
int target;
cin>>target;
for(int i=0;i<n;i++){
	arr[i];
}
printPairs(arr, n, target); 
return 0; 

}

you are not taking the i/p in the correct order

target has to be taken after the array elements are inputed.

Output format also need to match the required format
if (arr[i] + arr[j] == target)
cout << arr[i] << " and "
<< arr[j] << endl;
Also try optimising the code

Sort the array before applying 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.