Whats wrong here

#include
using namespace std;
int main() {
int n;

cin>>n;
int  cumulative sum=0;

int a[100];
for (int i=0;i<=n;i++){
	cin>>a[i];
}
for (int i=0;i<=n;i++){
	
	 cumulative sum= cumulative sum+a[i];
	 if (a[i]<0){
		 break;
	 }
	 cout<<i<endl;

}
return 0;

}

You have to store the numbers in a vector or array as long as the cumulative sum >=0. And in the end, you have to display the contents of the vector.


Check this code and tell me if you are able to understand it.

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.

I have edited your code… Try to submit now.
https://ide.codingblocks.com/s/227579