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

What is scope of a variable? (LOLZ)

2 Answers   CA, TCS,


C is to C++ as 1 is to a) What the heck b) 2 c) 10

0 Answers  


What is virtual methods?

0 Answers  


Is multimap sorted c++?

0 Answers  


Which coding certification is best?

0 Answers  






What c++ library is string in?

0 Answers  


What does count ++ do in c++?

0 Answers  


What is a static element?

0 Answers  


How static variables and local variablesare similar and dissimilar?

0 Answers  


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

0 Answers   Yahoo,


What does it mean to declare a member function as virtual?

0 Answers  


How can a struct in c++ differs from a struct in c?

0 Answers  


Categories