0
DECLARE SUB cube(!)
INPUT "Enter a length";l
CALL cube(l)
END
SUB cube(l)
area=6*l^2
PRINT "Area of a cube",area
END SUB
DECLARE SUB cube(!)
INPUT "Enter a length";l
CALL cube(l)
END
SUB cube(l)
area=6*l^2
PRINT "Area of a cube",area
END SUB
这剪断介绍调用QBasic的子程序得到一个立方体的领域:
DECLARE SUB Cube(L!)
INPUT "Enter a length"; L!
CALL Cube(L!)
END
SUB Cube (L!)
Area! = 6 * L!^2
PRINT "Area of a cube"; Area!
END SUB
的!声明一个变量为单精度。
我认为这是一个印刷错误; QB 4.5,PDS 7.1或QB64都不会运行代码。如果它像'DECLARE SUB cube(value!)'那样,就会运行。 –
qbasic成功运行上面的代码,但我不明白的是使用惊叹号(!) –
'!'用作变量的后缀来告诉QB它们是'SINGLE'变量。 –