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
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
English,
6 months ago
English,
6 months ago
World Languages,
6 months ago
Physics,
1 year ago
Political Science,
1 year ago
Math,
1 year ago