Computer Science, asked by Anonymous, 1 year ago

Write a program in Java to input two integer numbers in the variables A and B. Swap the values of the variables without using a third variable.

Answers

Answered by hiramani7080
14
import java.util*;
class SwapingValues
{
public static void main(String args[ ] )
{
Scanner obj= new Scanner (System.in);

int A,B;

System.out.println("Enter a number");
A=obj.nextInt( );

System.out.println("Enter a number");
B=obj.nextInt( );

A=A+B;
B=A-B;
A=A-B;

System.out.println("Swapped Values are");

System.out.println(A);
System.out.println(B);
}
}


hiramani7080: if my answer is correct and satisfactory then make it a brainliest question
Answered by Diganta69
3
this is the relevant answer
Attachments:
Similar questions