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.
2 Réponses
+ 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 ;
0
Thanks man,