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
Explain what is the stack?
What is data structure in c programming?
How can I read and write comma-delimited text?
What is the difference between call by value and call by reference in c?
Is Exception handling possible in c language?
how can f be used for both float and double arguments in printf? Are not they different types?
What is a 'null pointer assignment' error?
what are the different storage classes in c?
When we use void main and int main?
When should you use a type cast?
Is fortran faster than c?
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.
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
Hai what is the different types of versions and their differences
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }