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 ambiguity in inheritance?

0 Answers  


Prepare me a program for the animation of train

0 Answers  


Explain the advantages of inheritance.

0 Answers   TCS,


What is a unary operator?

5 Answers  


different types of castings

3 Answers   Siemens,






how do u initialize the constant variables

5 Answers   IBM, Siemens,


what is inline function?

3 Answers  


What does <> mean pseudocode?

0 Answers  


ambiguity regulation of multiple inheritance with example.

1 Answers  


What are main features of oop?

0 Answers  


What is oops and why we use oops?

0 Answers  


Explain the concept of abstracion and encapsulation with one example. What is the difference between them?

3 Answers   PCS,


Categories