forked from mayankgb2/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap.java
More file actions
17 lines (17 loc) · 439 Bytes
/
swap.java
File metadata and controls
17 lines (17 loc) · 439 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;
class SwapNumbers
{
public static void main(String args[])
{
int z, y, temp;
System.out.println("Enter z and y");
Scanner sct = new Scanner(System.in); //User inputs two numbers
z = sct.nextInt(); //User inputs two numbers
y = sct.nextInt();
System.out.println("Before Swapping\nz = "+z+"\ny = "+y);
temp = z; //Swapping is done
z = y;
y = temp;
System.out.println("After Swapping\nz = "+z+"\ny = "+y);
}
}