how to swap two numbers with out using temp variable

Answer Posted / guest

another way is using bitwise XOR (^).

a=9; //a=1001
b=5; //b=0101

a=a^b; //a=1100
b=a^b; //b=1001
a=b^a; //a=0101

Is This Answer Correct ?    29 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what are accessor methods?

759


Explain overriding.

679


What is c++ vb?

704


Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?

1831


What are the uses of pointers?

663






What is singleton pattern in c++?

633


What is a manipulator in c++?

793


What is auto type c++?

722


What are c++ manipulators?

701


Give an example of run-time polymorphism/virtual functions.

646


What is namespace std; and what is consists of?

781


What is the best it certification?

700


What is c++ iterator?

739


What is the basic of c++?

705


What does new return if there is insufficient memory to make your new object?

682