swapping of two numbers without using third variable using
AND and OR operators

Answers were Sorted based on User's Feedback



swapping of two numbers without using third variable using AND and OR operators..

Answer / ramesh reddy

a = a^b; b =a^b; a =a^b;
or
a=a+b; b=a-b; a=a-b;

Is This Answer Correct ?    43 Yes 2 No

swapping of two numbers without using third variable using AND and OR operators..

Answer / vignesh1988i

however we can implement using EXoR , where it is made of
AND and OR gate too....

x=90;
y=51;
x^=y^=x;
the value of x & y will be swapped.

Is This Answer Correct ?    8 Yes 8 No

Post New Answer

More C Interview Questions

which is the best antivirus and how to update it

7 Answers   Infosys,


where does malloc() function get the memory?

1 Answers  


Why structure is used in c?

0 Answers  


#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?

4 Answers   IIIT,


What is a void * in c?

0 Answers  






What are enumerated types?

0 Answers  


How can you increase the size of a statically allocated array?

0 Answers   TISL,


What is the difference between pure virtual function and virtual function?

0 Answers  


What are types of preprocessor in c?

0 Answers  


What does void main return?

0 Answers  


What is #define used for in c?

0 Answers  


1)which of following operator can't be overloaded. a)== b)++ c)?! d)<=

16 Answers   CybOrg, Siemens,


Categories