what is the use of operator ^ in C ? and how it works?
Answers were Sorted based on User's Feedback
Answer / vinay sachan
exclusive OR ^ is a bitwise operator known as (left assoc).
expr1 ^ expr2
ex.
0x12 ^ 0x58
returns 0x4A (the set bits in the result are those that are set in either 0x12 or 0x58, but not set in both).
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / 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 |
explain about storage of union elements.
What's a good way to check for "close enough" floating-point equality?
What are preprocessor directives?
What is the use of printf() and scanf() functions?
Please write the area of a RIGHT ANGLED TRIANGLE.
How does #define work?
Print the foll in C...eg when n=5 the o/p must b + + + + + + + + + + + + + + + + +
What does static mean in c?
wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain
How can I swap two values without using a temporary?
code for replace tabs with equivalent number of blanks
What is oops c?