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

what is the output of the following program and explain the answer #include<stdio.h> exp() { main(5) } main(int a) { printf("%d",a); return; }

3 Answers   Satyam,


without using arithmatic operator solve which number is greater??????????

1 Answers   Accenture,


Without using main fn and semicolon,print remainder for a given number in C language

2 Answers  


What is data type long in c?

0 Answers  


What are qualifiers?

0 Answers  


name the language for writing c compiler?

3 Answers   Microsoft,


Why is malloc used?

1 Answers  


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

0 Answers  


Explain c preprocessor?

0 Answers  


#include<stdio.h> int main() { int a[3][3][2]= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}; printf("%d\n",*(*(*a+1)); return 0; } What will be the output of the above question? And how?

1 Answers   Groupon,


What is the difference between declaring a variable and defining a variable?

0 Answers  


 write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare.  You will then tabulate this information in another file.

0 Answers  


Categories