What is the error?

#include
#include
#include
using namespace std;
int main() {
//cout<<“Enter the no of elements:”;
int n;
cin>>n;
int a[10];
//cout<<“Enter the element you want sum of:”;
sort(a,a+n);
//for(int i=0;i<n;i++)
//{
// int k;
// cin>>k;
// a[i]=k;
//}
int sum;
cin>>sum;
vector b;

for(int i=0;i<n;i++)
{
int sub=sum-a[i];
for(int k=0;k<n;k++)
{
if(a[k]==sub)
{
// cout<<a[i]<<"and "<<“sub:”<<sub<<endl;
b.push_back(a[i]);
break;
}

}

}

for(int i=0;i<b.size()/2;i++)
{
cout<<b[i]<<" and "<<sum-b[i]<<endl;
}

}

hey @manseerat,actually you have never taken array as an input.take array input then sort it .still faces problem copy your code in https://ide.codingblocks.com/ and save it and send me the link so that i can see it see it clearly.

#include
#include
#include
using namespace std;
int main() {

//cout<<“Enter the no of elements:”;
int n;
cin>>n;
int a[1000];
//cout<<“Enter the element you want sum of:”;
sort(a,a+n);
for(int i=0;i<n;i++)
{
int k;
cin>>k;
a[i]=k;
}
int sum;
cin>>sum;
vector b;

for(int i=0;i<n;i++)
{
int sub=sum-a[i];
for(int k=0;k<n;k++)
{
if(a[k]==sub)
{
// cout<<a[i]<<"and "<<“sub:”<<sub<<endl;
b.push_back(a[i]);
break;
}

}

}

for(int i=0;i<b.size()/2;i++)
{
cout<<b[i]<<" and "<<sum-b[i]<<endl;
}
}

hey @manseerat i have updated your code a little bit and commented IMP parts please look into it for hrlp (https://ide.codingblocks.com/s/180849)

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.