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
Write a program to know whether the input number is an armstrong number.
What is "Duff's Device"?
Can a pointer be null?
What is the difference between class and object in c?
What is the value of c?
What functions are used in dynamic memory allocation in c?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
Explain pointer. What are function pointers in C?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
What is NULL pointer?
What is a volatile keyword in c?
What are the key features in c programming language?
What are the different types of C instructions?
What is const and volatile in c?
What is calloc()?