bas7ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
INPUT Statement Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the INPUT statement to prompt the user for a value and
'assign it to a variable. The program calculates the area of a circle.
 
CLS
PI = 3.141593 : R = -1
DO WHILE R
    PRINT "Enter radius (or 0 to quit)."
    INPUT ; "If radius = ", R
    IF R > 0 THEN
        A = PI * R ^ 2
        PRINT ", the area of the circle ="; A
    END IF
    PRINT
LOOP
 
'Sample Output
'
'Enter radius (or 0 to quit).
'If radius = 3, the area of the circle = 28.27434
'
'Enter radius (or 0 to quit).
'If radius = 4, the area of the circle = 50.26549
'
'Enter radius (or 0 to quit).
'If radius = 0