Og N.

asked • 11/11/20

Given the pseudocode

procedure thing(a_1,a_2,a_3,...a_n:integers)

sum1 := 0

sum2 := 0

for i := 1 to n

if (a_i > 0), sum1 := sum1 + a_i

if (a_i < 0), sum2 := sum2 + a_i

end-for

return(sum1,sum2)


For the set of values {1,5,-2,-9,2,5,-7} as input for the above algorithm, what are the values of sum1 and sum2 that will be returned?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.