Write a program in java to find the swapping of two numbers without using third variabla.
Sample Input : x-10 y-20 Output : x-20 y-10
Answers
Answered by
0
Answer:
class demo {
public static void main(string arg[]) {
System.out.println("Before swapping");
int x = 10;
int y = 20;
System.out.println("value of x:" + x);
System.out.println("value of y:" + y);
system.out.println("After swapping");
x = x + y;
y = x - y;
x = x - y;
System.out.println("value of x:" + x);
System.out.println("value of y:" + y);
}
}
Explanation:
Similar questions
Math,
15 days ago
English,
15 days ago
Science,
1 month ago
World Languages,
1 month ago
Biology,
9 months ago
Computer Science,
9 months ago
Social Sciences,
9 months ago