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


Please Help Members By Posting Answers For Below Questions

What do you mean by enumerated data type?

567


What is a constructor in c++ with example?

574


What is capacity in vector in c++?

539


explain the reference variable in c++?

566


What operators can you overload in c++?

588






Do you need a main function in c++?

550


give me an example for testing a program showing the test path .show how the test is important and complex.

2417


Difference between an inspector and a mutator

760


Explain how we implement exception handling in c++?

571


What are the uses of typedef in a program?

603


Explain the differences between private, public and protected and give examples.

563


What are exceptions c++?

583


Differentiate between late binding and early binding. What are the advantages of early binding?

574


Which sort is best for the set: 1 2 3 5 4 a) Quick Sort b) Bubble Sort c) Merge Sort

656


What is the difference between the indirection operator and the address of oper-ator?

600