diff --git a/swap_two_num_without_using_temp_variable.java b/swap_two_num_without_using_temp_variable.java new file mode 100644 index 0000000..ae0d5c1 --- /dev/null +++ b/swap_two_num_without_using_temp_variable.java @@ -0,0 +1,16 @@ +import java.util.*; +class SwapTwo{ + public static void main(String a[]) + { + System.out.println("Enter the value of x and y"); + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + System.out.println("before swapping numbers: "+a +" "+ b); + /*Swapping*/ + a = a + b; + b = a - b; + a = a - b; + System.out.println("After swapping: "+a +" " + b); + } +}