why is my code failing some of the test cases?
Simple input challenge
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.
Hello @Arshabh,
Your code will fail for the case when the sum will become 0.
Example:
1
-1
3
4
Your Output:
1
Expected Output:
1 -1 3 4
Reason:
You are terminating loop for sum equals to and less than 0.
But 0 is not a negative number.
I have corrected your code:
https://ide.codingblocks.com/s/215513
Hope, this would help.
Give a like if you are satisfied.