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 |
List the difference between a 'copy constructor' and a 'assignment operator' in C?
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
What should malloc() do?
What are the advantages and disadvantages of c language?
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
Simplify the program segment if X = B then C ← true else C ← false
What is string function in c?
Write a function that accepts two numbers,say a and b and makes bth bit of a to 0.No other bits of a should get changed.
2 Answers Scientific Atlanta, Wipro,
write a program to generate address labels using structures?
What are the properties of union in c?
What is fflush() function?
given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the array which of the following is incorrect? a.*(a+5) b.a[5] c.pa[5] d.*(*pa + 5)