Simple Input Problem Set

Sir in this code can you please tell me what mistake did I do-
#include
using namespace std;
int main(){
int sum = 0;
int n ;
for(sum>=0;sum==sum + n;(scanf("%d",&n)!=EOF)){
cout<<n<<endl;
}

return 0;	

}

Due to which I am not getting any output.

Hi @Riankk, in this code pls check the condition of your for loop. It will be false on the first iteration itself and therefore nothing will be printed.

krishanu u r doing sum==sum+n and u didnt intialize n so n is a garbage thats why u r nor getting output

Sir, can you please explain what should be the correct code and how to use the scanf.

I edited int n; to cin>> n;

take example
0
5
u will get 0 as output

HI @Riankk, can you pls tell what is the question or task ?!?!?!?!?

Sir, we can input any number of values. But the output will contain only those values serially whose cumulative sum > 0,i.e, the moment the cumulative sum is negative , we have to stop processing the input.