How to modify this code to print the output in sorted form

#include<bits/stdc++.h>
using namespace std;
void targetSum(int arr[], int n, int s)
{
for (int i=0; i<n; i++){
for (int j=i+1; j<n; j++){
int sum = arr[i]+arr[j];
if (sum==s){
cout<<arr[i]<<" and "<<arr[j]<<endl;
}
}
}

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

hi @discobot sort the array before calling the function

Hi! To find out what I can do, say @discobot display help.