
Patrick B. answered 11/12/20
Math and computer tutor/teacher
The sum of the positive integers is 13
The sum of the negative integers is -18
Og N.
asked 11/11/20procedure 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?
Patrick B. answered 11/12/20
Math and computer tutor/teacher
The sum of the positive integers is 13
The sum of the negative integers is -18
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.