WAP in Java to interchange the value of two numbers, without using the third variable
Answers
Answered by
0
Explanation:
class Interchange
{
public static void main(int x, int y)
{
System.out.println("Before swapping");
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( "Interchanged value of x=" +x);
System.out.println( "Interchanged value of y=" +y);
}
}
Similar questions
Social Sciences,
2 months ago
Social Sciences,
2 months ago
History,
11 months ago
Chemistry,
11 months ago