Simple input question

here is my code its not passing all test cases can you tell which all testcases i should look for.

thankyou

#include
using namespace std;
int main()
{
int n;
int sum=0;
cin>>n;
while(n<1000 )
{
sum=sum+n;

	if(sum+n>n)
	{
		cout<<n<<" ";

	}
	else
	{
		break;

	}
	cin>>n;
	
}
return 0;

}

hi @akash_281 your logic is incorrect. why are you using a while loop for n? You dont need to manually check for the constraints. Secondly, you need to see if sum is negative or positive, so the condition sum +n > n does not make sense either. I’d suggest you to do a dry run of your code on the given sample input to further understand the issue with this logic.
please share your code by saving it on ide.codingblocks.com in the future

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.