Category Archives: Bit

Swap two number

Swap two number with temporary variable or arithmetic operations.

Latest Source Code:
Github: SwapTwoNumber.java


Output:

 Before swap - a:10, b:4
After swap - a:4, b:10
Before swap - a:100, b:200
After swap - a:200, b:100
Before swap - a:-10, b:4
After swap - a:4, b:-10
Before swap - a:100, b:-200
After swap - a:-200, b:100
Before swap - a:-10, b:-4
After swap - a:-4, b:-10
Before swap - a:-100, b:-200
After swap - a:-200, b:-100