Write a program in Java to swap two numbers
Answers
Answered by
1
Answer:
Java Program to Swap Two Numbers
- 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
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
History,
5 months ago
Math,
11 months ago
Political Science,
1 year ago
Economy,
1 year ago
English,
1 year ago