package com.instanceofjava;

public class SwapTwoNumbers{
public static void main(String args[]){
        int x =10;
        int y =20
        System.out.println("Before swaping:");
        System.out.println("x value is: "+x);
        System.out.println("y value is: "+y);
        x = x+y;
        y=x-y;
        x=x-y;
        System.out.println("After swaping:");
        System.out.println("x value is: "+x);
        System.out.println("y value is: "+y);
    }
}


Output:
Before swaping:
x value is :10
y value is:20

After swaping:
x value is :20
y value is :10






Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu