Given two integer numbers and we have to swap them with and without using third variable.
Swapping of two numbers program is very common and important program, Here we are implementing this program in Java using two methods:
- Using third variable
Here, we will use a temporary variable to swap the numbers.
- Without using third variable
Here we will not use any temporary variable to swap the numbers.
-
Consider the programs:
1) Swapping of numbers using third variable
Output
2) Swapping of numbers without using third variable
Output
need an explanation for this answer? contact us directly to get an explanation for this answer