freebasic-examples/src/addsub.fb.bas

35 lines
818 B
QBasic

#lang "fblite"
dim as integer max,a,b,n,i
print
input "Maximum absolute value of the numbers [default: 100]: ";max
if max<2 then
max=100
end if
print
input "How many examples [default: 25] ";n
if n<=0 then
n=25
end if
Print ' output on the printer
Print
Print
Print " ";n;" arithmetical exercises with integral numbers from ";-max;" to";max
Print
Print
randomize 'initialize the rnd random-number generator
for i=1 to n
a=int(rnd*(2*max+1))-max
b=int(rnd*(2*max+1))-max
Print using " ###) ";i;
Print a;
if b<=0 then
Print " -";abs(b)
else
Print " +";b
end if
'Print
'Print
next i
Print Chr(12) ' for output on computer screen use the command "sleep"