2 test cases failing why?

include
using namespace std;
int main()
{
int i,j,A[10],n,no;
cin>>n;

for(i=0; i<n ;i++)
{

     cin>>A[i];
	
}
cin>>no;
for(i=0;i<n;i++)
{   j=n-1;
	while(i<j)
{
	if(A[i]+A[j]==no)
{
	cout<<A[i]<<" and "<<A[j]<<endl;
	break;
}
	else
	{
		j--;
	}
}
}
return 0;

}

save your code at


and share the link generated

Modified Code

2 mistakes

  1. size of array is only 10 but constraints are large
    Constraints
    Length of the arrays should be between 1 and 1000.

  2. ans pairs should be in increasing order so first sort the array and then process