X=5 Y=6 # to swap X and Y, introduce a temporary variable Z Z=X X=Y Y=Z #### X=X+Y Y=X-Y X=X-Y # I know this solution is not perfect: # when X and Y are big, there is a danger of overflow.