Write a Program to swap two numbers without using temporary variable

We need to write a Program to swap two numbers without using temporary variable. We can achieve this by using mathematical operations.

Java Program to swap two numbers without using temporary variable

Output

Variables Before Swapping Value of a : 5 Value of b : 10 Variables After Swapping Value of a : 10 Value of b : 5

Leave a Reply

Your email address will not be published. Required fields are marked *