Averages/Root mean square: Difference between revisions

m (→‎{{header|REXX}}: added overflow to 'style', changed comments, added comments, added whitespace. -- ~~~~)
(→‎{{header|BASIC}}: added qbasic)
Line 127:
print "RMS: ",sqrt(S/N);
}</lang>
 
=={{header|BASIC}}==
{{works with|QBasic}}
 
Note that this will work in [[Visual Basic]] and the Windows versions of [[PowerBASIC]] by simply wrapping the module-level code into the <code>MAIN</code> function, and changing <code>PRINT</code> to <code>MSGBOX</code>.
 
<lang qbasic>DIM i(1 TO 10) AS DOUBLE, L0 AS LONG
FOR L0 = 1 TO 10
i(L0) = L0
NEXT
PRINT STR$(rms#(i()))
 
FUNCTION rms# (what() AS DOUBLE)
DIM L0 AS LONG, tmp AS DOUBLE, rt AS DOUBLE
FOR L0 = LBOUND(what) TO UBOUND(what)
rt = rt + (what(L0) ^ 2)
NEXT
tmp = UBOUND(what) - LBOUND(what) + 1
rms# = SQR(rt / tmp)
END FUNCTION</lang>
 
See also: [[#BBC BASIC|BBC BASIC]], [[#Liberty BASIC|Liberty BASIC]], [[#PureBasic|PureBasic]], [[#Run BASIC|Run BASIC]]
 
=={{header|BBC BASIC}}==
1,150

edits