Computer Science, asked by sweetyswe006, 11 months ago

Write a program in Java to swap two numbers

Answers

Answered by shobha3238
1

Answer:

Java Program to Swap Two Numbers

  1. public class SwapNumbers {

2. float first = 1.20f, second = 2.45f;

3. println("--Before swap--");

4. println("First number = " + first);

5. println("Second number = " + second);

6. // Value of first is assigned to temporary.

float temporary = first;

7. // Value of second is assigned to first.

Explanation:

Hope it will help

Mark me BRAINLIEST

Answered by wwwshanayasingh4582
1

Answer:

class SwapNumbers{

public void doSwapping(){

int x = 11 ,y =7;

int temp;

System.out.println("before Swapping\n x="+x+"\ny="+y);

temp= x;

x=y;

y=temp;

System.out.println("after swapping\n x ="+x+"\ny="+y);

}

}

Similar questions