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

When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??

13 Answers   HCL, Honeywell,


what is mean by design pattern

4 Answers  


What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<<v(); } 1) 1 2) 0 3) Code cannot compile

4 Answers  


There are 2 empty jars of 5 and 3 liters capacity. And a river is flowing besides. I want to measure 4 liters of wanter using these 2 jars. How do you do this?

2 Answers  


//what is wrong with the programme?? #include<iostream.h> template <class first> class dd { first i; public: void set(); void print(); }; void dd< first>:: set() { cin>>i; } void dd< first>::print() { cout<<"\n"<<i; } void main() { dd <char>g; g.set(); g.print(); }

1 Answers  


Write an operator overloading program to Overload ‘>’ operator so as to find greater among two instances of the class.

1 Answers  


how to write a java program for an output ****0 ***01 **012 *0123 01234

1 Answers  


What is encapsulation in oops?

0 Answers  


c++ provides classes...and classes do what we want but why then strcut are used...if we say data hiding... it is also provided by c++ in structs then why to prefer clasess

1 Answers   HCL, TCS,


What is a mixin class?

4 Answers  


What is the significance of classes in oop?

0 Answers  


What is a class in oop?

0 Answers  


Categories