Computer Science, asked by dassubhasis450, 9 months ago

Write an algorithm to input 2 numbers and swap the values?​

Answers

Answered by Ainatripathi
2

Answer:

class Swap

{

public static void main (String.args[ ]);

{

int a = Sc.next Int ();

int b = Sc.next Int ();

a = a + b

b = a - b

a = a - b

S.O.P.ln (c)

}

}

Answered by it192110147
0

Answer:

Q/ Write an algorithm that inputs 2 numbers and swaps them.

Explanation:

public static void main(String[]args)

   {

       Scanner input=new Scanner(System.in);

       System.out.print("Enter the x: ");

       int x=input.nextInt();

       System.out.print("Enter the y: ");

       int y=input.nextInt();

       x=x+y;

       y=x-y;

       x=x-y;

       System.out.println("x: "+x);

       System.out.println("y: "+y);

   }

Similar questions