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 |
#include<stdio.h> main() { int a=1; int b=0; b=++a + ++a; printf("%d %d",a,b); }
Explain how do you list a file’s date and time?
What is the use of clrscr?
What does typeof return in c?
Is it better to use a macro or a function?
why TCS selected more student in the software field from all institution.
Why array starts with index 0
Whats s or c mean?
a character variable can at a time store a) 1 character b) 8 characters c) 254 characters d) none of the above
Can I initialize unions?
write a program to generate address labels using structures?
write a c program to find largest of three numbers using simple if only for one time.