Question: C++!!! 9 THE negativeSum PROBLEM Write a function negativeSum that accepts an input stream and an output stream as arguments, and returns a true/false value.

C++!!!

C++!!! 9 THE negativeSum PROBLEM Write a function negativeSum that accepts an

9 THE negativeSum PROBLEM Write a function negativeSum that accepts an input stream and an output stream as arguments, and returns a true/false value. The input stream contains a series of integers. Your function should determine whether the running sum, starting from the first number is ever negative. For example, if the input consists of the following: 38 4 19-27 -15 -3 4 19 38 The first number is 38 (not negative), the sum of the next (38 4), the sum of the next (384 +19), and so on up to the sum of all of the numbers. None of these sums is negative, so the function would produce the following output and return false. no negative sum If the file instead contains the following numbers, the function finds that a negative sum of -8 is reached after adding 6 numbers together (14 7 + -10 + 9 + -18 -10) 14 7-10 9 -18 -10 17 42 98 It should output the following, indicating that a negative sum can be reached, and return true. -8 after 6 steps

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!