how to swap two numbers with out using temp variable

Answers were Sorted based on User's Feedback



how to swap two numbers with out using temp variable..

Answer / dd

a=1
b=2
a=a+(b-a)
b=(a+b)-b

Is This Answer Correct ?    12 Yes 16 No

how to swap two numbers with out using temp variable..

Answer / kusum

if (a>b)
temp=a;
a=b;
b=temp;

Is This Answer Correct ?    0 Yes 21 No

Post New Answer

More C++ General Interview Questions

Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

0 Answers  


What happens when the extern "c" char func (char*,waste) executes?

0 Answers  


What is the use of default constructor?

0 Answers  


Explain the difference between 'operator new' and the 'new' operator?

1 Answers   Lucent, TCS,


You run a shell on unix system. How would you tell which shell are you running?

0 Answers  






What is a wchar_t in c++?

0 Answers  


What is an incomplete type in c++?

0 Answers  


What is :: operator in c++?

0 Answers  


What is size of null class?

6 Answers   HP,


Differentiate between the message and method?

1 Answers  


What are the 3 levels of programming languages?

0 Answers  


What happens when you make call 'delete this;'?

0 Answers  


Categories