We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dbb41ce commit 7c9b9c2Copy full SHA for 7c9b9c2
1 file changed
Basic Codes/Swapnum.java
@@ -0,0 +1,22 @@
1
+import java.util.Scanner;
2
+
3
+class Swapnum
4
+{
5
+ public static void main(String args[])
6
+ {
7
+ int num1, num2, temp; //create temp variable for storing value
8
+ System.out.println("Enter number1 and number2");
9
+ Scanner in = new Scanner(System.in);
10
11
+ num1 = in.nextInt();
12
+ num2 = in.nextInt();
13
14
+ System.out.println("Before Swapping\nnum1 = "+num1+"\nnum2 = "+num2); //before swap
15
16
+ temp = num1; //temp assign to num1
17
+ num1 = num2;
18
+ num2 = temp;
19
20
+ System.out.println("After Swapping\nnum1 = "+num1+"\nnum2 = "+num2);
21
+ }
22
+}
0 commit comments