Arrays target sum pairs

#include
using namespace std;
void print(long int n,int a[],int target){
int r,g;
for(int i=0;i<n;i++){
r=a[i];
for(int j=0;j<n;j++){
g=a[j];
if((r+g)==target){
if(r<g){
cout<<r<<" “<<“and”<<” "<<g<<endl;
}
}
}
}
}
int main(){
long int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int target;
cin>>target;
print(n,a,target);
return 0;
}

@Saksham12 hey saksham please share your code through ide.codingblocks.com
And this problem need sorting input before apply operation so use inbuilt sort function.