Home > Algorithms
Swap (Posted on 2004-01-02 )

In programming, a common task is to swap the values of two variables. Lines 40-60 of the program below perform the swap using a temporary variable (T).
10 A=123
20 B=456
30 PRINT A,B
40 T=A
50 A=B
60 B=T
70 PRINT A,B
Rewrite the program to swap the values in A and B without using a temporary variable.
Note: The new program will not require sophisticated programming or complex math.

Comments: (
You must be logged in to post comments. )

Please log in:
Forums (0)
Newest Problems
Random Problem
FAQ |
About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On
Chatterbox: