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 do you mean by enumerated data type?
What is a constructor in c++ with example?
What is capacity in vector in c++?
explain the reference variable in c++?
What operators can you overload in c++?
Do you need a main function in c++?
give me an example for testing a program showing the test path .show how the test is important and complex.
Difference between an inspector and a mutator
Explain how we implement exception handling in c++?
What are the uses of typedef in a program?
Explain the differences between private, public and protected and give examples.
What are exceptions c++?
Differentiate between late binding and early binding. What are the advantages of early binding?
Which sort is best for the set: 1 2 3 5 4 a) Quick Sort b) Bubble Sort c) Merge Sort
What is the difference between the indirection operator and the address of oper-ator?