Computer Science, asked by kalpana2006, 1 year ago

Write a program in java to interchange the value of two numbers without using the third variable.



Plz give a perfect program....

I WILL MARK U AD THE BRAINLIEST.​

Answers

Answered by iamemma112358
3

PROGRAM CODE

import java.util.*;

class demo

{ public static void main(String args[])

{ Scanner sc=new Scanner(System.in);

int a,b;

System.out.println("Enter two numbers:");

a=sc.nextInt();

b=sc.nextInt();

a=a+b;

b=a-b;

a=a-b;

System.out.println("Swapped value of a=" + a);

System.out.prinrln("Swapped value of b=" + b);

}

}

VARIABLE DESCRIPTION

a and b- Both the variables are used to store the numbers as entered by the user.

Similar questions