Program to swap two numbers
Java program to swap two numbers
public class SwapNumbers {
public static void main(String[] args) {
float first = 1.20f, second = 2.45f;
System.out.println("--Before swapping--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
float temporary = first;
first = second;
second = temporary;
System.out.println("--After swapping--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
}
}
public class SwapNumbers {
public static void main(String[] args) {
float first = 1.20f, second = 2.45f;
System.out.println("--Before swapping--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
float temporary = first;
first = second;
second = temporary;
System.out.println("--After swapping--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
}
}
Comments
Post a Comment