SIMPLE INPUT PROBLEM

MY CODE IS NIT GETTING PASSED FOR 1 TEST CASE

if(sum>0)
{
cout<<n<<endl;
}
Here correct condition should be
if(sum>=0)
{
cout<<n<<endl;
}

ok i will try
this code now

it is still failing 1 test case

one change you also have to do that is
cin>>n;
while(n){}

if n is 0 then you will not enter inside loop but you have to enter

so just replace n to true

#include<iostream>
using namespace std;

int main() {

	int n;
	int sum = 0;
	cin >> n;
	while (true)
	{
		sum = sum + n;
		if (sum >= 0)
		{
			cout << n << endl;
		}

		if (sum < 0)
		{
			return 0;
		}
		cin >> n;

	}
	return 0;
}

done the code and understood too
send feedback 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.