code passes third test case if i write
sum>=0
and fails when sum>0
why this happens
Simple input third test case
Hey Pratik, can you share your code, so that we can help you with the exact issue in the code.
Heyy Pratik , i think you shared the wrong code . Can you share the code for this particular question ?
#include
using namespace std ;
int main() {
int i, sum=0;
while(1){
cin>>i;
sum=sum+i;
if(sum>=0) {cout<<i<<endl;}
else {break;}
}
return 0;
}
Yeah ! Itβs obvious that sum>=0 should get accepted because its mentioned in the question that you have to print the input until the cummulative sum becomes negative i.e you have to print n till sum>=0 .
Is it clear now ?
I want to know why third test case fails for sum>0 but pass if sum>=0
because it is given that you have to stop processing when sum becomes negative only and when sum>=0 that means sum is not negative if sum > 0 or sum=0
2 Likes