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
Fifoernik
  • 9,779
  • 1
  • 21
  • 27
Binod Thakur
  • 53
  • 1
  • 6
  • I think it's a typographical error; none of QB 4.5, PDS 7.1, or QB64 will run the code. If it was something like `DECLARE SUB cube(value!)`, that would run. –  Aug 05 '16 at 05:18
  • qbasic successfully run the above code but what i didnot understand is the use of exclamation sign (!) – Binod Thakur Aug 05 '16 at 09:42
  • 2
    The `!` is used as a suffix on variables to tell QB that they are `SINGLE` variables. –  Aug 05 '16 at 10:56

1 Answers1

2

This snip describes calling a subroutine in QBasic to get the area of a cube:

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

The ! declares a variable as single precision.

eoredson
  • 1,167
  • 2
  • 14
  • 29