0

Can any one suggest me how to write this simple program ?

A program that takes sequence of real numbers and then compute both products of all positive and all negative numbers in that sequence and write them out with an accuracy of three decimal places.

6th Feb 2018, 1:14 PM
Mohibur Moni
Mohibur Moni - avatar
2 odpowiedzi
+ 5
get the sequence as input ; float prod_pos = 1.0 ; float prod_neg = 1.0 ; loop through the list, number by number: if number is positive: prod_pos = prod_pos * number ; if number is negative: prod_neg = prod_neg * number ; print prod_pos and prod_neg ;
6th Feb 2018, 2:03 PM
Pedro Demingos
Pedro Demingos - avatar
0
Thanks man,
6th Feb 2018, 2:04 PM
Mohibur Moni
Mohibur Moni - avatar