Java Program to Swap Two Numbers
mrt481 0.9K 28th Aug, 2022
Loading Please wait...
In the above program, two numbers 1.20f and 2.45f which are to be swapped are stored in variables: first and second respectively. The variables are printed before swapping using println() to see the results clearly after swapping is done. First, the value of first is stored in variable temporary (temporary = 1.20f). Then, value of second is stored in first (first = 2.45f). And, finally value of temporary is stored in second (second = 1.20f). This completes the swapping process and the variables are printed on the screen. Remember, the only use of temporary is to hold the value of first before swapping. You can also swap the numbers without using temporary.
- C++ Program to Add Two Numbers
C++ | 5.7K | 11 months ago
- C++ Program to Print Number Entered by User
C++ | 3.3K | 11 months ago
- C++ "Hello, World!" Program
C++ | 2.4K | 11 months ago