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 |
2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x);
What is non linear data structure in c?
How would you print out the data in a binary tree, level by level, starting at the top?
code for selection sort?
What is the difference between realloc() and free()
What is table lookup in c?
how to find that no is int or float?
what is the use of macro program
program to convert a integer to string in c language'
what is ans for this scanf(%%d",c);
What is define c?
what is a function prototype?