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

hi i m deepak my shedule for NIC pi is 17 Apr please contact me if anybody has interview on same day or give me some idea who have faced

1563


Given a cube of size n*n*n (i.e made up of n^3 smaller cubes), find the number of smaller cubes on the surface. Extend this to k-dimension.

677


1.what is the vesition managment.

1686


how can we maintain the previous version scripts to new version.

1429


Give examples of macro quoting function?

1552






hai i am mca 2009 fresher.please tell me which certification helps me to get an IT job faster which institute is good in hyderabad.please mail me to prasanna.1856@rediff.com

1528


what is d main diff between the java and .net framework

1548


what is the difference between an OS(operating system) and Framework?

1524


i am exeprienced person what is selection process

1132


why we use abstract in awt?

1560


How to create a new dataset only duplicate observations in proc sort procedure?

1616


in IT trend mantis meant what? how to know mantis in IT trends? detail description about mantis?

1649


Hello Experts, What is the difference between move and move corresponding exactly? please post me asap

1337


when will triggars the at new event in abap and web dybn pro?

1494


Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.

650