Write a Program Swipping Two Number with Varaible using java- Technology369kk

 Program:

import java.util.Scanner;

class SwappingTwoNo {
public static void main(String[] args) {
int x, y, temp;
System.out.println("Enter x and y Num:");
Scanner sc = new Scanner(System.in);
x = sc.nextInt();
y = sc.nextInt();

System.out.println("Before Swapping: \n x= "+x+"\n y="+y);

temp = x;
x = y;
y = temp;

System.out.println("After Swapping: \n x= "+x+"\n y="+y);
}
}
 

 

Answer: 

 


Enter x and y Num:
5
6
Before Swapping:
x= 5
y=6
After Swapping:
x= 6
y=5
 

Post a Comment

0 Comments