Wednesday, February 6, 2019

To Swap 2 numbers

 //To swap 2 numbers

import java.util.*;

class Prog
{
  public static void main(String args[ ])
  {
    Scanner ob =new Scanner (System.in);

    System.out.print("Enter the numbers:");
    int x=ob.nextInt( ) ;
    int y=ob.nextInt( ) ;

   System.out.println("Before Swapping value of  First variable :"+x);
   System.out.println("Before Swapping value of  Second variable :"+y);


   y=y+x - (x=y);

   System.out.println("After Swapping value of  First variable :"+x);
   System.out.println("After Swapping value of  Second variable :"+y);

   }

}





10 comments:

  1. Hello sir. I think I am first to comment. I am Priyanshu Ghosh of class 6. Awesome sir and very helpful.

    ReplyDelete
  2. Sir,it was quite helpful. Can you please post the program to input two different dates and display the total days between the two

    ReplyDelete
  3. Thank you, sir
    I am Bidisha Biswas of class 8A

    ReplyDelete
  4. Thank u ,sir
    I am Sonia ghosh of class 8A

    ReplyDelete
  5. sir i am bodhisattwa sarkar of class 8 a
    thanks for the program

    ReplyDelete
  6. SIR CAN YOU PLEASE EXPRESS THE FORMAT OF THE DATE COUNT

    ReplyDelete
  7. Thank u sir, it was vry helpful!!!
    BARNAK GHOSH CLASS 8 C

    ReplyDelete

  3.WAP IN JAVA TO INPUT THREE NUMBERS AND COUNT HOW MANY OF THEM ARE EVEN .   import java.util.*; class Prog {   public static ...