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

  • Easy to Customize

  • Customizable fonts.

Wednesday, December 16, 2015

Swapping the values of two variables with temp variable:

import java.util.*;
public class Swapping
{
  public static void main()
  {
      int x,y,temp;
      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();
      temp = x;
      x = y;
      y = temp;
      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