how to swap two numbers with out using temp variable
Answer Posted / a.g.dhivyalakshmi
//swaping of 2 numbers without using temp variable
//a=5 & b=6
a=a+b; //a=30
b=a-b; //b=5
a=a-b; //a=6
//Thus two numbers are swapped
// or
//a=5 & b=6
a=a*b; //a=30
b=a/b; //b=5
a=a/b; //a=6
//Thus two numbers are swapped
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
What is setw manipulator in c++?
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
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
What is singleton class in c++?
How const int *ourpointer differs from int const *ourpointer?
What is the difference between while and do while loop? Explain with examples.
What is the protected keyword used for?
What is operator overloading in c++ example?
Why do we use constructor?
Do class declarations end with a semicolon?
What is overloading unary operator?
What kind of jobs can I get with c++?
What is the use of lambda in c++?
What you know about structures in C++?
What is the oldest programming language?