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

What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }

0 Answers   SRA,


What is the difference between the C & C++?

9 Answers   HCL,


WHAT IS THE DIFFERENCE BETWEEN OBJECT BASED & OBJECT ORIENTD PROGRAMMING LANGUAGE.(GIVE AT LIST 4 PIONT)

1 Answers   TCS,


write a progra in c++ using class & object to find out wheather a given no. is prim or not.

2 Answers  


Please send ford technologies placement paper 2 my mail id

0 Answers  


What is the full form of oops?

0 Answers  


What is abstraction in oops?

0 Answers  


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

0 Answers  


How do you define a class in oop?

0 Answers  


what is multithreading in c++ , what is difference between multithreading and singlethreading.

4 Answers  


what is the new version of oops

0 Answers   Ignou,


monkey starts climbing up a tree 20ft tall,each hour ,it hops 3ft and slips back by 2ft .how much time it wil tak to reach top of the tree?

13 Answers   IonIdea,


Categories