The code which I wrote

#include
using namespace std;
int main() {
int n;
int a[n];
cin>>n;
int l=1;
int r=n;
int target=n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
while(l<r){
jump:
if(l+r==target){
cout<<l<<" and "<<r<<endl;
l++;
r–;
}
else{
r–;
goto jump;
}
}

return 0;

hi @Ambuj-Singh-514796906079795 what is your doubt? please save your code on ide.codingblocks.com and share the link

#include using namespace std; int main() { int n; int a[n]; cin>>n; int l=1; int r=n; int target=n; for(int i=1;i<=n;i++){ cin>>a[i]; } while(l<r){ jump: if(l+r==target){ cout<<l<<" and "<<r<<endl; l++; r–; } else{ r–; goto jump; } } return 0;

@Ambuj-Singh-514796906079795 what is your doubt?

#include
#include
using namespace std;
int main() {
int n,a[100];
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
int l=a[0];
int r=a[n-1];
int target;
cin>>target;

while(l<r){
jump:
if(l+r==target){
cout<<l<<" and "<<r<<endl;
l++;
r–;
}
else{
r–;
goto jump;
}
}
return 0;
}

It is showing that I am failing one test case???

@Ambuj-Singh-514796906079795 you dont need to use jump statement, because the flow of control of the while loop will take you there anyway. Secondly, your code is not giving any output for the following test input
2
1 1
2

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.