Write a macro for swapping integers

Answers were Sorted based on User's Feedback



Write a macro for swapping integers..

Answer / deepak

# define swap(a,b) a = a + b; b = a - b; a = a - b;

Is This Answer Correct ?    50 Yes 8 No

Write a macro for swapping integers..

Answer / suresh

swap(a,b) a^=b^=a^=b;

Is This Answer Correct ?    12 Yes 3 No

Write a macro for swapping integers..

Answer / balaji ramdoss

#define SWAP(a,b) b=a+b-(a=b)

Is This Answer Correct ?    19 Yes 12 No

Write a macro for swapping integers..

Answer / raku

#define SWAP(a,b) a=a+b-(b=a)

Is This Answer Correct ?    1 Yes 0 No

Write a macro for swapping integers..

Answer / sun

#define SWAP(a,b) (a^=b^=a^=b;)

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More OOPS Interview Questions

Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

0 Answers   Accenture,


What is the example of polymorphism?

0 Answers  


what is oops

4 Answers   NIIT,


How to execute business logic for only once ..?even though user clicks submit button multiple times by mistake..? (i disabled JavaScript)

1 Answers  


What is polymorphism in oop example?

0 Answers  






What is oops in programming?

0 Answers  


WRITE A SIMPLE C++ PROGRAM TO SWAP TWO NOS WITHOUT USING TEMP

2 Answers  


What is the oops and benefits of oops programming?

0 Answers  


What is the difference between class and object?

4 Answers   Apple, Heinz,


What is abstraction with example?

0 Answers  


What is the difference between declaration and definition?

20 Answers   IBS,


Explain polymorphism? What r the types of polymorphism? pls give examples?

4 Answers   HCL,


Categories