-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwap.java
More file actions
30 lines (25 loc) · 740 Bytes
/
Swap.java
File metadata and controls
30 lines (25 loc) · 740 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
30
import java.util.Scanner;
public class Swap {
public static void main(String agrs[])
{
Scanner ad = new Scanner(System.in);
System.out.println("Enter two number for swapping :- ");
int a = ad.nextInt();
int b = ad.nextInt();
System.out.println("before swapping value is :-");
System.out.println("a :- " +a);
System.out.println("b :- " +b);
int c;
c=a;
a=b;
b=c;
/*
a= a+b; without third variable;
b= a-b;
a= a-b
*/
System.out.println("After Swapping value is :-");
System.out.println("a :- " +a);
System.out.println("b :- " +b);
}
}