Still 2 testcases failing
@Tusharbhatia15
The mistakes you are doing is:
1 We need to stop only when the sum becomes < 0,and you are stoping when any negative number comes,because your sum gets initialised everytime as sum=0 inside while and it losses its previous value,as sum is declared inside the while functional scope.
Try to give sum global scope so that we can check it on the next iterations of while.
2 Dont use inside else as it will terminate when any negative number comes.
For e.g: 6 3 -2,the sum is positive but your code will terminate and print 6 3 as the output.
But in the correct manner,the code shouldn’t be terminated and the output should be processed as sum is still >0 .
Hit like if it helps,and come back with the updated code,we will be glad to help you again.