How to swap values between two variables without using a
third variable?

Answer Posted / siva

You can also do it with the exclusive or bitwise operator...
a = a ^ b;
b = a ^ b; ((a ^ b) ^ b == a)
a = a ^ b; ((a ^ b) ^ a == b)

Is This Answer Correct ?    27 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the main usage of an abstract keyword?please follow the program class A { void display() { System.out.println("hai"); } void print() { } } class B extends A { void print() { System.out.println("Hello"); } } In this program i was gives the implementation of print() according to my requirements in subclass.And there is no definition in superclass then why we can use abstract keyword before a method that i want to gives definition in other classes,is any mistakes in the above usage of method?

1473


write a query that returns one row for each department and the number of employees in that department. Given two tables EMPLOYEE and DEPARTMENT, where there can be multiple employees per department.

1174


can any one suggestion me present which course(except java,.net) has huge demand in the market?

1613


Is buffer size and file block size is similar? If similar,at which case it will be same size?

1731


3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....

1663






what do u mean by tagging

1614


what is c sharp dotnet

1734


Hi can you please send me recent(present) interview questions and technical qyestions with answers for "BUSSIESS OBJECTS" and "DATA WAREHOUSE".pls its urgent for me my mail id is sekhar.cs82@gmail.com,manjuforgis@gmail.com. thanks in advance

1483


Which method protects back button to retrieve old value from previous page in Struts.

1444


how to convert infix expression to prefix expression?

3823


pleasew define carrier scope in abap (sap).

2100


why we use abstract word in abstract window toolkit in java language.

1759


what is class module in vb6? what it's use? with example..

1946


differences between qtp10.0 and 11.0 ?

1808


Tag for turning an image into a hyperlink is

1835