Sum and product of an array: Difference between revisions
Content added Content deleted
(Added solution for Action!) |
(Sum and product of an array en QBasic) |
||
Line 2,322: | Line 2,322: | ||
<lang python>import math |
<lang python>import math |
||
total = math.fsum(floats)</lang> |
total = math.fsum(floats)</lang> |
||
=={{header|QBasic}}== |
|||
{{works with|QBasic}} |
|||
{{works with|QuickBasic}} |
|||
{{works with|True BASIC}} |
|||
<lang QBasic>DIM array(1 TO 5) |
|||
DATA 1, 2, 3, 4, 5 |
|||
FOR index = LBOUND(array) TO UBOUND(array) |
|||
READ array(index) |
|||
NEXT index |
|||
LET sum = 0 |
|||
LET prod = 1 |
|||
FOR index = LBOUND(array) TO UBOUND(array) |
|||
LET sum = sum + array(index) |
|||
LET prod = prod * array(index) |
|||
NEXT index |
|||
PRINT "The sum is "; sum |
|||
PRINT "and the product is "; prod |
|||
END</lang> |
|||
=={{header|Quackery}}== |
=={{header|Quackery}}== |