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
It's good to share...Share on FacebookTweet about this on TwitterShare on LinkedInPin on PinterestShare on Google+Email this to someone

Leave a Reply

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