Simple Input challenge 1

Cant understand the problem, this is what i understand

#include
using namespace std;
int main() {
int n;
int sum=0;
while(scanf("%d",&n)!=EOF)
{
//cout<<n<<endl;
while(sum>=0)
{
sum=sum+n;
if(sum<0)
{
break;
}
}

	if( n<0)
	{   
		
		break;
	}
	cout<<n<<endl;
}
return 0;

}

hey @sujeetmandloi23, it is the way of taking steaming input, where you are getting input unknown number of times,

Hey Gaurav, then what should i do?? what is the process??

hey @sujeetmandloi23 just print all the numbers before the sum become negative.

while(scanf("%d",&n)!=EOF)
{
sum+=n;
if(sum<0)
{
break;
}
else
{
cout<<n<<endl;
}