Swapping of two numbers

Swapping of two numbers
 
     SWAPPING

            This is the program to swap between

            two values.

 FOR EXAMPLE -:

  •  let's take two values 

    a=23

    b=35

    and after swapping with some logic the value will be

    a=35

    b=23

                           The following  program is done by using 3rd variable

     class swapping

 {

    public static void main(String[]args)

        {

          int a=34,b=67,c;

       System.out.print("The value of a before swapping is : "+a) ;

       System.out.print("The value of b before swapping is : "+b) ;

          c=a;

          a=b;

          b=c;

       

      System.out.print("The value of a after swapping is : "+a) ;

      System.out.print("The value of b after swapping is : "+b) ;

       } 

}

OUTPUT

Swapping of two numbers

Post a Comment

0 Comments