Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
Basicgames (talk | contribs) |
Basicgames (talk | contribs) |
||
Line 859: | Line 859: | ||
=={{header|Craft Basic}}== |
=={{header|Craft Basic}}== |
||
<syntaxhighlight lang="basic"> |
<syntaxhighlight lang="basic">dim a[3, 1, 4, 1, 5, 9] |
||
dim a[3, 1, 4, 1, 5, 9] |
|||
arraysize s, a |
arraysize s, a |
||
Line 871: | Line 869: | ||
next i |
next i |
||
print t / s |
print t / s</syntaxhighlight> |
||
{{out| Output}}<pre>3.83</pre> |
|||
end</syntaxhighlight> |
|||
<syntaxhighlight lang="basic">'version 2: without using an array |
|||
input "how many numbers to average? ", n |
|||
for i = 1 to n |
|||
input "enter a number: ", s |
|||
let a = a + s |
|||
next i |
|||
print "average: ", a / n |
|||
end</syntaxhighlight> |
|||
=={{header|Crystal}}== |
=={{header|Crystal}}== |