import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
long sum = cin.nextLong(), temp = 0;
if(sum>0){
System.out.println(sum);
}
while(sum>0){
long n = cin.nextLong();
if(n>0){
System.out.println(n);
}
temp = sum;
sum = sum + n;
}
}
}===============what’s the error in the code
Problem simple input
hi @AbhishekAhlawat1102
you are only printing positive numbers not negative numbers buts its not necessary that negative numbers will make the cumulative sum negative.
lets take eg.
Sample input
1
2
88
-20
-30
-100
49
Sample Output:
1
2
88
-20
-30
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.