I am not not able to complete first question

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,sum=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
sum+=a[i];
if(sum>=0)
{
cout<<a[i]<<endl;
}
else
break;
}
}

You just have to take input until cumulative sum becomes negative. So you can take an infinite while loop as while(true)…and take the inputs within the loop…maintain cumulative sum within the loop…as soon as your cumulative sum becomes less than 0…break the loop…
Try to code on your own…If you face any problem then please save your code on ide.codingblocks.com and then share its link.

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.