Target sum pairs

code:
include iostream
using namespace std;

int main() {
int n;
cin>>n;
int a[n];
int start=0,end=n-1;
int curr_sum=0;
for(int i=0;i<n;i++)
{
cout<<a[i]<<endl;
}

int given_sum;
cin>>given_sum;
while(start<end)
{
    curr_sum=a[start]+a[end];
    if(curr_sum<given_sum)
    start++;
    else if(curr_sum>given_sum)
    end--;
    else
	{
    cout<<a[start]<<" and "<<a[end];
    start++;
    end--;
	}
}

}

Here’s your debugged code, have added comments too for better understanding

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.