-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap.java
More file actions
29 lines (26 loc) · 749 Bytes
/
Copy pathswap.java
File metadata and controls
29 lines (26 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class swap {
public static void main(String[] args) {
int a, b;
System.out.print("Enter the Value for A= ");
Scanner ac = new Scanner(System.in);
a = ac.nextInt();
System.out.print("Enter the Value for B= ");
Scanner bc = new Scanner(System.in);
b = bc.nextInt();
System.out.println("A is: " + a);
System.out.println("B is: " + b);
// useing three variable
// int c;
// c = a;
// a = b;
// b = c;
a = a + b;
b = a - b;
a = a - b;
System.out.println(
);
System.out.println("A is: " + a);
System.out.println("B is: " + b);
}
}