Filter by Tags

Swapping Numbers without using 3rd variable

Votes

0

0 0
This Question is asked to:

Write a Program of Swapping Numbers without using 3rd variable.

Manish Rawat
Posted on : Wed, Jan 24, 2018
Views : 61
Comments

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


0
public class JavaSwapExample

{ public static void main(String[] args)

{

int x = 10; int y = 20;

System.out.println("Before Swapping");

System.out.println("Value of x is :" + x);

System.out.println("Value of y is :" + y);

//add both the numbers and assign it to first

x = x + y;

y = x - y;

x = x - y;

System.out.println("after Swapping");

System.out.println("Value of x is :" + x);

System.out.println("Value of y is :" + y);

} }



Jaspreet kaur
Thu, Jan 25, 2018
Loading...
Comments

Edit Answer

Submit
This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp