Answers for "java program to swap two numbers without using the third variable"

1

swap two variables without temporary java

import java.*; 
  
class noTemp { 
  
    public static void main(String a[]) 
    { 
        int x = 10; 
        int y = 5; 
        x = x + y; 
        y = x - y; 
        x = x - y; 
        System.out.println("After swaping:"
                           + " x = " + x + ", y = " + y); 
    } 
}
Posted by: Guest on January-22-2021
0

java program to swap two numbers

int a, b, c;
a = 5;
b = 3;
System.out.println("Before SWAP a = " + a + ", b = " + b);
c = a;
a = b;
b = c;
System.out.println("After SWAP a = " + a + ", b = " + b);
Posted by: Guest on November-11-2020
0

swap two numbers java

int a = 5;
int b = 6;

int temp = a;
a = b;
b = temp;

// now a is 6 and b is 5.
Posted by: Guest on August-06-2021

Code answers related to "java program to swap two numbers without using the third variable"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language