Simple input program

I won’t be able to solve this problem please give me the solution and explain me

Initially we take sum = 0, then we keep on reading numbers and adding them to sum till sum >= 0. as soon as sum becomes negative we stop there.
Refer to this code.


Hope it clears all ur doubts.

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.

I had one q why we inputing after loop like in this q while(sum>=0) after that we are inputing cin>>num in the next line why please explain me

basically we have to stop when sum becomes negative. until then we keep on reading numbers and keep on adding them to sum. as soon as sum becomes negative the loop terminates. and this is what is asked in question

I akesd that why after loop we are inputing no why not before and if we are putting before loop cin>>num what will happen

so u can do one thing store all the numbers in an array then iterate over them.

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.

please explain me in this I haven’t studied array till now and I have to clear my concept what will happen if we inputing before loop please explain me