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

4)What would be the output? main() { int num=425; pf("%d",pf("%d",num)); } a)Comp error b)4425 c)4253 d)3435 e)none

10 Answers  


What is #define used for in c?

0 Answers  


Why are all header files not declared in every c program?

0 Answers  


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

0 Answers  


20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????

2 Answers  






State the difference between x3 and x[3].

0 Answers   Aricent,


Do you know the use of 'auto' keyword?

0 Answers  


difference of two no's with out using - operator

7 Answers  


What is an array? What the different types of arrays in c?

0 Answers  


What are the 32 keywords in c?

0 Answers  


where can function pointers be used?

2 Answers  


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

0 Answers   HCL,


Categories