import java.io.*;
import java.util.Scanner;
public class swaptwovariables
{
public static void main(String args[]) throws Exception
{
System.out.println("Welcome to the swaptwovariables project!");
Scanner input = new Scanner(System.in);
System.out.println("Enter two numbers a and b to swap");
int a= input.nextInt();
int b= input.nextInt();
System.out.println("a and b before swapping "+a+" "+b);
a=a+b;
b=a-b;
a=a-b;
System.out.println("a and b after swapping "+a+" "+b);
}
}
import java.util.Scanner;
public class swaptwovariables
{
public static void main(String args[]) throws Exception
{
System.out.println("Welcome to the swaptwovariables project!");
Scanner input = new Scanner(System.in);
System.out.println("Enter two numbers a and b to swap");
int a= input.nextInt();
int b= input.nextInt();
System.out.println("a and b before swapping "+a+" "+b);
a=a+b;
b=a-b;
a=a-b;
System.out.println("a and b after swapping "+a+" "+b);
}
}
Comments
Post a Comment