I am not getting the output help me to get output in simple input program

Help me in executing this code

@tarunasree123 firstly, you dont have to worry about the constraints. They are provided to give you an idea about what kind of data structure to use and should be the time complexity of the code. Secondly, you dont have to check if the number is negative or not, you have to check if the cumulative sum of all the numbers is negative or not.
Your code might go into an infinite loop because the condition for your while loop is while(N>-1000 && N<1000) and it will ALWAYS be positive because the constraints guarantee it. Your code will not stop untill a negative number is entered and again there is no guarantee of that.

Please try to analyze your mistake and wrtite the code again. I am attaching a working code for your reference, so you can fully understand what the question is asking.

#include<iostream>
using namespace std;
int main() {
	int N, sum = 0;
	cin>>N;
    sum = sum + N; // keep track of the sum
    while (sum >= 0) { //check if sum is positive
        cout << N << "\n"; //print the value of prev n
        cin >> N; //take new input
        sum += N; //update sum
    } 
	return 0;
}

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.