ProAnswers.org

How do you swap two numbers in qbasic?

How do you swap two numbers in qbasic?

MS-DOS QBasic Version 1.1

SWAP Exchanges the values of two variables.

SWAP variable1, variable2

variable1 and variable2 Two variables of the same data type.

Example:
a% = 1: b% = 2
PRINT "Before: "; a%, b%
SWAP a%, b%
PRINT "After: "; a%, b%