for this code i am getting null values as answer
please tell me what is the error in this code
#include
#include<bits/stdc++.h>
using namespace std;
main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
int target=0;
cin>>target;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]+a[j]==target)
{ cout<<a[i]<<“and”<<a[j]<<endl;
}
}
cout<<endl;
}
}
Output is zero coming
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.