-
Notifications
You must be signed in to change notification settings - Fork 0
/
Que2.java
31 lines (22 loc) · 678 Bytes
/
Que2.java
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
31
// add apakage
import java.util.Scanner;
public class Que2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the first variable a : ");
//Take first variable as input
int a = sc.nextInt();
System.out.println("Enter the second variable b : ");
//Take second variable as input
int b = sc.nextInt();
int temp = a;//Declare a variable temp and assign it vale of a
//Assign a value to b
a = b;
// assign temp value to b ie value of a
b = temp;
// Print both swap varuiable
System.out.println("First variable a : " + a);
System.out.println("Second variable b : " + b);
sc.close();
}
}