:::: MENU ::::
  • Suitable for all screen sizes

  • Easy to Customize

  • Customizable fonts.

Wednesday, December 16, 2015


Swapping the values of two variables without temp variable:

import java.util.*;
public class Swapping
{
  public static void main()
  {
      int x,y;
      Scanner sc=new Scanner(System.in);
      System.out.println("Please enter the numbers you want to swap values of");
      x=sc.nextInt();
      y=sc.nextInt();
      x = x + y;
      y = x - y;
      x = x - y;
      System.out.println("Swapped values are: " +x+", "+y);
     
  }
}
Thank you and make sure to like and comment.

0 comments:

Post a Comment

A call-to-action text Contact us