Jump to content

Soloway's recurring rainfall: Difference between revisions

Soloway's Recurring Rainfall in various BASIC dialents (BASIC256, QBASIC and Yabasic)
m (→‎{{header|Raku}}: Add a Raku example)
(Soloway's Recurring Rainfall in various BASIC dialents (BASIC256, QBASIC and Yabasic))
Line 95:
END
</syntaxhighlight>
 
=={{header|BASIC}}==
==={{header|QBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
{{works with|FreeBASIC}}
<syntaxhighlight lang="qbasic">n = 0
sum = 0
 
DO
INPUT "Enter integral rainfall (99999 to quit): ", i
IF (i < 0) OR (i <> INT(i)) THEN
PRINT "Must be an integer no less than 0, try again."
ELSEIF i = 99999 THEN
EXIT DO
ELSE
n = n + 1
sum = sum + i
PRINT " The current average rainfall is"; sum / n
END IF
LOOP</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="BASIC256">n = 0
sum = 0
 
while True
input "Enter integral rainfall (99999 to quit): ", i
if i = 99999 then exit while
if (i < 0) or (i <> int(i)) then
print "Must be an integer no less than 0, try again."
else
n += 1
sum += i
print " The current average rainfall is "; sum/n
end if
end while</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
==={{header|Yabasic}}===
<syntaxhighlight lang="yabasic">// Rosetta Code problem: https://rosettacode.org/wiki/Soloway%27s_Recurring_Rainfall
// by Jjuanhdez, 09/2022
 
n = 0
sum = 0
 
do
input "Enter integral rainfall (99999 to quit): " i
if (i < 0) or (i <> int(i)) then
print "Must be an integer no less than 0, try again."
elsif i = 99999
break
else
n = n + 1
sum = sum + i
print " The current average rainfall is ", sum/n
end if
loop</syntaxhighlight>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
 
=={{header|C}}==
2,169

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.