Testcases failed,, wat is wrong in the code please explain

#include
using namespace std;

void sumpairs(int a[500],int n,int target){
for(int i=0;i<n; i++){

	for(int j=0;j<n;j++){
		if(i!=j && i<j){
			if(a[i]+a[j]==target){
				cout<<a[i]<<" and "<<a[j]<<endl;
			}
		}
	}
}

}
int main() {
int n;cin>>n;
int a[500]={0};
for(int i=0;i<n;i++){
cin>>a[i];
}

int target;
cin>>target;
sumpairs(a,n,target);

return 0;

}

Hello @thakur0_0,

Mistakes:

  1. Size of your array.
    Problem:
    You are not following the constraints specified in the question:
    Length of the arrays should be between 1 and 1000.

  2. There are two more mistakes.
    I have specified them in the code below:

Corrected Code:

Hope, this would help.
Give a like if you are satisfied.