Sum and product of an array: Difference between revisions
Content added Content deleted
(Sum and product of an array in Chipmunk Basic) |
|||
Line 512: | Line 512: | ||
PRINT "The product is ",product |
PRINT "The product is ",product |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
==={{header|Chipmunk Basic}}=== |
|||
{{works with|Chipmunk Basic|3.6.4}} |
|||
{{works with|QBasic}} |
|||
<syntaxhighlight lang="qbasic">10 rem Sum and product of an array |
|||
20 dim array(4)' array de 5 eltos. |
|||
30 data 1,2,3,4,5 |
|||
40 for index = 0 to ubound(array) |
|||
50 read array(index) |
|||
60 next index |
|||
70 sum = 0 |
|||
80 prod = 1 |
|||
90 for index = 0 to 4 ubound(array) |
|||
100 sum = sum+array(index) |
|||
110 prod = prod*array(index) |
|||
120 next index |
|||
130 print "The sum is ";sum |
|||
140 print "and the product is ";prod |
|||
150 end</syntaxhighlight> |
|||
==={{header|BBC BASIC}}=== |
==={{header|BBC BASIC}}=== |