what is the use of operator ^ in C ? and how it works?

Answer Posted / rahul mathur

^ is a exclusive OR bitwise operator.

We can use this "^" operator for swaping two values without
using third variable and without using +, - operator as
shown below:

void xorSwap (int *x, int *y) {
if (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the stack?

831


What is data structure in c programming?

786


How can I read and write comma-delimited text?

824


What is the difference between call by value and call by reference in c?

872


Is Exception handling possible in c language?

1786


how can f be used for both float and double arguments in printf? Are not they different types?

802


What is a 'null pointer assignment' error?

934


what are the different storage classes in c?

851


When we use void main and int main?

795


When should you use a type cast?

798


Is fortran faster than c?

774


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1441


the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above

993


Hai what is the different types of versions and their differences

1713


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1467