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.
PRINT Statement Programming Examples
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'These three examples show the use of commas and semicolons with the
'PRINT statement.
'This example uses commas in a PRINT statement to print each value at
'the beginning of the next print zone.
CLS 'Clear screen.
X = 5
PRINT X + 5, X - 5, X * (-5), X ^ 5
END
'Sample Output
'
' 10 0 -25 3125
'In this example, the semicolon at the end of the first PRINT
'statement makes the first two PRINT statements print on the
'same line. The last PRINT statement prints a blank line before
'the next prompt.
CLS 'Clear screen.
DO
INPUT "Input X (type 0 to quit): ", X
IF X = 0 THEN
EXIT DO
ELSE
PRINT X; "squared is"; X ^ 2; "and";
PRINT X; "cubed is"; X^3
PRINT
END IF
LOOP
'Sample Output
'
'Input X (type 0 to quit): 9
' 9 squared is 81 and 9 cubed is 729
'
'Input X (type 0 to quit): 21
' 21 squared is 441 and 21 cubed is 9261
'
'Input X (type 0 to quit): 0
'In this example, the semicolons in the PRINT statement print each
'value immediately after the preceding value. Note that a space
'always follows a number and precedes a positive number.
CLS 'Clear screen.
FOR X = 1 TO 5
J = J + 5
K = K + 10
PRINT J; K;
NEXT X
'Sample Output
'
' 5 10 10 20 15 30 20 40 25 50