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 |
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
Define C in your own Language.
whether itis a structured language?
how can we use static and extern?and where can we use this?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
pgm to reverse string using arrays i.e god is love becomes love is god) (assumption:only space is used for seperation of words) no addtional memory used.i.e no temporary arrays can used.
How can you pass an array to a function by value?
25. It takes five minutes to pass a rumour from one person to two other persons. The tree of rumour continues. Find how many minutes does it take spread the rumour to 768 persons. ?
11 Answers CTS, TCS,
Explain what is the benefit of using #define to declare a constant?
How do I declare a pointer to an array?
What does == mean in texting?
Explain what is the advantage of a random access file?