Do we know how many input we have to take or we just assume it 5?
How to eleminate the -100
Please share your question
hi @AVIRAL1101
you have to stop taking sum becomes less than 0.
No need to store any values in any array, Just take a variable sum to store the total sum, and another variable to take inputs. I am writing the algorithm below, hope it helps in clarifying the logic.
declare the variables, n, sum = 0.
take input for n, cin >> n
add n to the sum, like sum = sum + n
while (sum >= 0) //do this till sum doesnt become negative
{
//print the last value of n that was added to the sum and didnt make the same negative
cout << n
//keep taking user input for more values
cin >> n
// keep appending it to the sum to update it
sum = sum + n
}
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.
