Problem 2.13


 Question 2.13: Write a Java program to swap two variables.


Solution: 


package com.company;
import java.util.Scanner;
public class Lab2problem13 {
    public static void main(String[] args)
    {
        Scanner Obj = new Scanner(System.in);
        System.out.println("Enter the first value: ");
        int n =Obj.nextInt();
        System.out.println("Enter the Secend value: ");
        int m =Obj.nextInt();

        System.out.println("swap two variables: "+n+m);
        System.out.println("other two variable is: "+m+n);
    }
}

Previous Post Next Post