Thursday, June 4, 2020

Write a program in java to input two number and Swap the Numbers (interchange the value) without using third variable.

3)  Write a program in java to input two number and Swap the Numbers (interchange the value) without using third variable.

public class Swaping_without_using_third_var
{
    public static void main(int a,int b)
    {
        System.out.println("a = "+a);
        System.out.println("b = "+b);
        a = a + b;
        b = a - b;
a = a - b;
        System.out.println();
        System.out.println("a = "+a);
        System.out.println("b = "+b);
    }
}


No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj