Skip to content

Commit 69050e7

Browse files
SwapNumber code
1 parent c505183 commit 69050e7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package DailyExercise;
2+
3+
import java.util.Scanner;
4+
5+
public class SwapNumber1 {
6+
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
10+
Scanner sc=new Scanner(System.in);
11+
System.out.println("Enter the value of a : ");
12+
int a=sc.nextInt();
13+
System.out.println("Enter the value of b : ");
14+
int b=sc.nextInt();
15+
16+
System.out.println("Before swapping a & b : ");
17+
System.out.println("a = "+a+", b = "+b);
18+
19+
a=a+b;
20+
b=a-b;
21+
a=a-b;
22+
23+
System.out.println("After swapping a & b : ");
24+
System.out.println("a = "+a+", b = "+b);
25+
26+
}
27+
28+
}

0 commit comments

Comments
 (0)