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
How do I run c++?
What is encapsulation in c++ with example?
Which software is best for programming?
Is there any function that can skip certain number of characters present in the input stream?
Why do we use double in c++?
Can you pass an array to a function in c++?
What do you mean by funtion prototype?
What is the difference between the parameter to a template and the parameter to a function?
What is c++ array?
Write a Program for find and replace a character in a string.
What is vector processing?
What are the various compound assignment operators in c++?
State the difference between delete and delete[].
What is the difference between struct and class?
What is else syntax in c++?