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

Write a corrected statement in c++ so that the statement will work properly. x =+ 7;

2 Answers  


How can you link a c++ program to c functions?

0 Answers  


What are c++ variables?

0 Answers  


Difference between overloading vs. Overriding

0 Answers  


Can a function take variable length arguments, if yes, how?

0 Answers  


What are different types of polymorphism supported by C++

2 Answers   CA, GameLoft,


What are function prototypes?

0 Answers  


Problem 5: Hero's Formula is A method for calculating the area of a triangle when you know the lengths of all three sides. Let a, b, c be the lengths of the sides of a triangle. The area is given by:A= pp-ap-b(p-c) | wherep= a+b+c2 | | Write a C-language code to calculate area of triangle using above method. Take the three lengths of the triangle from the user and display the area that your program calculates.

0 Answers   Maxobiz,


an integer constant must have atleast one a) character b) digit c) decimal point

0 Answers  


Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort

0 Answers  


What return value must conversion operators have in their declaration?

0 Answers  


Describe the main characteristics of static functions?

1 Answers  


Categories