Input
Output
public class SwapWithoutTemp { public static void main(String[] args) { // Manually assigned numbers int num1 = 10; int num2 = 25; System.out.println("Enter the first number: " + num1); System.out.println("Enter the second number: " + num2); // Display original values System.out.println("Before swapping: num1 = " + num1 + ", num2 = " + num2); // Swap without using a temporary variable num1 = num1 + num2; num2 = num1 - num2; num1 = num1 - num2; // Display swapped values System.out.println("After swapping: num1 = " + num1 + ", num2 = " + num2); } }