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 are Access specifiers in C++ class? What are the types?
Differentiate between realloc() and free().
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
Explain unexpected() function?
What is the difference between public and private data members?
What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random
Explain function overloading
What are pointers used for c++?
How do I use arrays in c++?
Why is c++ difficult?
What is a buffer c++?
Does c++ vector allocate memory?
What is &x in c++?
What is Destructor in C++?
What does the nocreate and noreplace flag ensure when they are used for opening a file?