Computer Science, asked by Saquiba1, 1 year ago

write a program in Java to interchange the value of two nos. without using 3rd variable.

Answers

Answered by Astrobolt
4
public class Interchange
{
public static void main(String args[])
{
int X = 5; //X = 5
int Y = 7; //Y = 7
int X = X + Y; //X = 12
int Y = X - Y; //Y = 5
int X = X - Y; //X = 7
}
}

And voila we have exchanged the values of two numbers without using a third variable.

Saquiba1: thanks a lot
Astrobolt: please mark as brainliest?
Saquiba1: okk i will mark it.....bt dear the program is nt clear to me
Astrobolt: so tell me which part is not clear
Similar questions