- public class SwapThreeNumberWithoutFourthVariable {
- public static void main(String[] args) {
- int a = 10;
- int b = 20;
- int c = 30;
- a = a + b + c;
- b = a - (b + c);
- c = a - (b + c);
- a = a - (b + c);
- System.out.println("after swap value of a: " + a);
- System.out.println("after swap value of b: " + b);
- System.out.println("after swap value of c: " + c);
- }
- }
Output:
after swap value of a: 30
after swap value of b: 10
after swap value of c: 20
No comments:
Post a Comment